41 |
|
import java.security.SecurityPermission; |
42 |
|
import java.util.ArrayList; |
43 |
|
import java.util.Arrays; |
44 |
+ |
import java.util.Collections; |
45 |
|
import java.util.Date; |
46 |
|
import java.util.Enumeration; |
47 |
|
import java.util.Iterator; |
63 |
|
import java.util.concurrent.Semaphore; |
64 |
|
import java.util.concurrent.SynchronousQueue; |
65 |
|
import java.util.concurrent.ThreadFactory; |
66 |
+ |
import java.util.concurrent.ThreadLocalRandom; |
67 |
|
import java.util.concurrent.ThreadPoolExecutor; |
68 |
|
import java.util.concurrent.TimeoutException; |
69 |
|
import java.util.concurrent.atomic.AtomicBoolean; |
1237 |
|
* Sleeps until the given time has elapsed. |
1238 |
|
* Throws AssertionFailedError if interrupted. |
1239 |
|
*/ |
1240 |
< |
void sleep(long millis) { |
1240 |
> |
static void sleep(long millis) { |
1241 |
|
try { |
1242 |
|
delay(millis); |
1243 |
|
} catch (InterruptedException fail) { |
1756 |
|
* A CyclicBarrier that uses timed await and fails with |
1757 |
|
* AssertionFailedErrors instead of throwing checked exceptions. |
1758 |
|
*/ |
1759 |
< |
public class CheckedBarrier extends CyclicBarrier { |
1759 |
> |
public static class CheckedBarrier extends CyclicBarrier { |
1760 |
|
public CheckedBarrier(int parties) { super(parties); } |
1761 |
|
|
1762 |
|
public int await() { |
1877 |
|
1000L, MILLISECONDS, |
1878 |
|
new SynchronousQueue<Runnable>()); |
1879 |
|
|
1880 |
+ |
static <T> void shuffle(T[] array) { |
1881 |
+ |
Collections.shuffle(Arrays.asList(array), ThreadLocalRandom.current()); |
1882 |
+ |
} |
1883 |
|
} |