8 |
|
|
9 |
|
/* |
10 |
|
* @test |
11 |
< |
* @summary JSR-166 tck tests |
11 |
> |
* @summary JSR-166 tck tests (conformance testing mode) |
12 |
|
* @build * |
13 |
+ |
* @modules java.management |
14 |
|
* @run junit/othervm/timeout=1000 JSR166TestCase |
15 |
|
*/ |
16 |
|
|
17 |
+ |
/* |
18 |
+ |
* @test |
19 |
+ |
* @summary JSR-166 tck tests (whitebox tests allowed) |
20 |
+ |
* @build * |
21 |
+ |
* @modules java.base/java.util.concurrent:open |
22 |
+ |
* java.base/java.lang:open |
23 |
+ |
* java.management |
24 |
+ |
* @run junit/othervm/timeout=1000 |
25 |
+ |
* -Djsr166.testImplementationDetails=true |
26 |
+ |
* JSR166TestCase |
27 |
+ |
* @run junit/othervm/timeout=1000 |
28 |
+ |
* -Djsr166.testImplementationDetails=true |
29 |
+ |
* -Djava.util.concurrent.ForkJoinPool.common.parallelism=0 |
30 |
+ |
* JSR166TestCase |
31 |
+ |
* @run junit/othervm/timeout=1000 |
32 |
+ |
* -Djsr166.testImplementationDetails=true |
33 |
+ |
* -Djava.util.concurrent.ForkJoinPool.common.parallelism=1 |
34 |
+ |
* -Djava.util.secureRandomSeed=true |
35 |
+ |
* JSR166TestCase |
36 |
+ |
* @run junit/othervm/timeout=1000/policy=tck.policy |
37 |
+ |
* -Djsr166.testImplementationDetails=true |
38 |
+ |
* JSR166TestCase |
39 |
+ |
*/ |
40 |
+ |
|
41 |
|
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
42 |
|
import static java.util.concurrent.TimeUnit.MINUTES; |
43 |
|
import static java.util.concurrent.TimeUnit.NANOSECONDS; |
63 |
|
import java.security.SecurityPermission; |
64 |
|
import java.util.ArrayList; |
65 |
|
import java.util.Arrays; |
66 |
+ |
import java.util.Collection; |
67 |
+ |
import java.util.Collections; |
68 |
|
import java.util.Date; |
69 |
|
import java.util.Enumeration; |
70 |
|
import java.util.Iterator; |
84 |
|
import java.util.concurrent.RecursiveTask; |
85 |
|
import java.util.concurrent.RejectedExecutionHandler; |
86 |
|
import java.util.concurrent.Semaphore; |
87 |
+ |
import java.util.concurrent.SynchronousQueue; |
88 |
|
import java.util.concurrent.ThreadFactory; |
89 |
+ |
import java.util.concurrent.ThreadLocalRandom; |
90 |
|
import java.util.concurrent.ThreadPoolExecutor; |
91 |
|
import java.util.concurrent.TimeoutException; |
92 |
+ |
import java.util.concurrent.atomic.AtomicBoolean; |
93 |
|
import java.util.concurrent.atomic.AtomicReference; |
94 |
|
import java.util.regex.Matcher; |
95 |
|
import java.util.regex.Pattern; |
213 |
|
Integer.getInteger("jsr166.suiteRuns", 1); |
214 |
|
|
215 |
|
/** |
216 |
< |
* The scaling factor to apply to standard delays used in tests. |
216 |
> |
* Returns the value of the system property, or NaN if not defined. |
217 |
|
*/ |
218 |
< |
private static final int delayFactor = |
219 |
< |
Integer.getInteger("jsr166.delay.factor", 1); |
218 |
> |
private static float systemPropertyValue(String name) { |
219 |
> |
String floatString = System.getProperty(name); |
220 |
> |
if (floatString == null) |
221 |
> |
return Float.NaN; |
222 |
> |
try { |
223 |
> |
return Float.parseFloat(floatString); |
224 |
> |
} catch (NumberFormatException ex) { |
225 |
> |
throw new IllegalArgumentException( |
226 |
> |
String.format("Bad float value in system property %s=%s", |
227 |
> |
name, floatString)); |
228 |
> |
} |
229 |
> |
} |
230 |
> |
|
231 |
> |
/** |
232 |
> |
* The scaling factor to apply to standard delays used in tests. |
233 |
> |
* May be initialized from any of: |
234 |
> |
* - the "jsr166.delay.factor" system property |
235 |
> |
* - the "test.timeout.factor" system property (as used by jtreg) |
236 |
> |
* See: http://openjdk.java.net/jtreg/tag-spec.html |
237 |
> |
* - hard-coded fuzz factor when using a known slowpoke VM |
238 |
> |
*/ |
239 |
> |
private static final float delayFactor = delayFactor(); |
240 |
> |
|
241 |
> |
private static float delayFactor() { |
242 |
> |
float x; |
243 |
> |
if (!Float.isNaN(x = systemPropertyValue("jsr166.delay.factor"))) |
244 |
> |
return x; |
245 |
> |
if (!Float.isNaN(x = systemPropertyValue("test.timeout.factor"))) |
246 |
> |
return x; |
247 |
> |
String prop = System.getProperty("java.vm.version"); |
248 |
> |
if (prop != null && prop.matches(".*debug.*")) |
249 |
> |
return 4.0f; // How much slower is fastdebug than product?! |
250 |
> |
return 1.0f; |
251 |
> |
} |
252 |
|
|
253 |
|
public JSR166TestCase() { super(); } |
254 |
|
public JSR166TestCase(String name) { super(name); } |
470 |
|
AbstractQueuedLongSynchronizerTest.suite(), |
471 |
|
ArrayBlockingQueueTest.suite(), |
472 |
|
ArrayDequeTest.suite(), |
473 |
+ |
ArrayListTest.suite(), |
474 |
|
AtomicBooleanTest.suite(), |
475 |
|
AtomicIntegerArrayTest.suite(), |
476 |
|
AtomicIntegerFieldUpdaterTest.suite(), |
493 |
|
CopyOnWriteArrayListTest.suite(), |
494 |
|
CopyOnWriteArraySetTest.suite(), |
495 |
|
CountDownLatchTest.suite(), |
496 |
+ |
CountedCompleterTest.suite(), |
497 |
|
CyclicBarrierTest.suite(), |
498 |
|
DelayQueueTest.suite(), |
499 |
|
EntryTest.suite(), |
522 |
|
TreeMapTest.suite(), |
523 |
|
TreeSetTest.suite(), |
524 |
|
TreeSubMapTest.suite(), |
525 |
< |
TreeSubSetTest.suite()); |
525 |
> |
TreeSubSetTest.suite(), |
526 |
> |
VectorTest.suite()); |
527 |
|
|
528 |
|
// Java8+ test classes |
529 |
|
if (atLeastJava8()) { |
530 |
|
String[] java8TestClassNames = { |
531 |
+ |
"ArrayDeque8Test", |
532 |
|
"Atomic8Test", |
533 |
|
"CompletableFutureTest", |
534 |
|
"ConcurrentHashMap8Test", |
535 |
< |
"CountedCompleterTest", |
535 |
> |
"CountedCompleter8Test", |
536 |
|
"DoubleAccumulatorTest", |
537 |
|
"DoubleAdderTest", |
538 |
|
"ForkJoinPool8Test", |
539 |
|
"ForkJoinTask8Test", |
540 |
+ |
"LinkedBlockingDeque8Test", |
541 |
+ |
"LinkedBlockingQueue8Test", |
542 |
|
"LongAccumulatorTest", |
543 |
|
"LongAdderTest", |
544 |
|
"SplittableRandomTest", |
545 |
|
"StampedLockTest", |
546 |
|
"SubmissionPublisherTest", |
547 |
|
"ThreadLocalRandom8Test", |
548 |
+ |
"TimeUnit8Test", |
549 |
|
}; |
550 |
|
addNamedTestClasses(suite, java8TestClassNames); |
551 |
|
} |
553 |
|
// Java9+ test classes |
554 |
|
if (atLeastJava9()) { |
555 |
|
String[] java9TestClassNames = { |
556 |
< |
// Currently empty, but expecting varhandle tests |
556 |
> |
"AtomicBoolean9Test", |
557 |
> |
"AtomicInteger9Test", |
558 |
> |
"AtomicIntegerArray9Test", |
559 |
> |
"AtomicLong9Test", |
560 |
> |
"AtomicLongArray9Test", |
561 |
> |
"AtomicReference9Test", |
562 |
> |
"AtomicReferenceArray9Test", |
563 |
> |
"ExecutorCompletionService9Test", |
564 |
> |
"ForkJoinPool9Test", |
565 |
|
}; |
566 |
|
addNamedTestClasses(suite, java9TestClassNames); |
567 |
|
} |
572 |
|
/** Returns list of junit-style test method names in given class. */ |
573 |
|
public static ArrayList<String> testMethodNames(Class<?> testClass) { |
574 |
|
Method[] methods = testClass.getDeclaredMethods(); |
575 |
< |
ArrayList<String> names = new ArrayList<String>(methods.length); |
575 |
> |
ArrayList<String> names = new ArrayList<>(methods.length); |
576 |
|
for (Method method : methods) { |
577 |
|
if (method.getName().startsWith("test") |
578 |
|
&& Modifier.isPublic(method.getModifiers()) |
639 |
|
|
640 |
|
/** |
641 |
|
* Returns the shortest timed delay. This can be scaled up for |
642 |
< |
* slow machines using the jsr166.delay.factor system property. |
642 |
> |
* slow machines using the jsr166.delay.factor system property, |
643 |
> |
* or via jtreg's -timeoutFactor: flag. |
644 |
> |
* http://openjdk.java.net/jtreg/command-help.html |
645 |
|
*/ |
646 |
|
protected long getShortDelay() { |
647 |
< |
return 50 * delayFactor; |
647 |
> |
return (long) (50 * delayFactor); |
648 |
|
} |
649 |
|
|
650 |
|
/** |
678 |
|
* The first exception encountered if any threadAssertXXX method fails. |
679 |
|
*/ |
680 |
|
private final AtomicReference<Throwable> threadFailure |
681 |
< |
= new AtomicReference<Throwable>(null); |
681 |
> |
= new AtomicReference<>(null); |
682 |
|
|
683 |
|
/** |
684 |
|
* Records an exception so that it can be rethrown later in the test |
957 |
|
}}; |
958 |
|
} |
959 |
|
|
960 |
+ |
PoolCleaner cleaner(ExecutorService pool, AtomicBoolean flag) { |
961 |
+ |
return new PoolCleanerWithReleaser(pool, releaser(flag)); |
962 |
+ |
} |
963 |
+ |
|
964 |
+ |
Runnable releaser(final AtomicBoolean flag) { |
965 |
+ |
return new Runnable() { public void run() { flag.set(true); }}; |
966 |
+ |
} |
967 |
+ |
|
968 |
|
/** |
969 |
|
* Waits out termination of a thread pool or fails doing so. |
970 |
|
*/ |
988 |
|
} |
989 |
|
} |
990 |
|
|
991 |
< |
/** Like Runnable, but with the freedom to throw anything */ |
991 |
> |
/** |
992 |
> |
* Like Runnable, but with the freedom to throw anything. |
993 |
> |
* junit folks had the same idea: |
994 |
> |
* http://junit.org/junit5/docs/snapshot/api/org/junit/gen5/api/Executable.html |
995 |
> |
*/ |
996 |
|
interface Action { public void run() throws Throwable; } |
997 |
|
|
998 |
|
/** |
1023 |
|
* Uninteresting threads are filtered out. |
1024 |
|
*/ |
1025 |
|
static void dumpTestThreads() { |
1026 |
+ |
SecurityManager sm = System.getSecurityManager(); |
1027 |
+ |
if (sm != null) { |
1028 |
+ |
try { |
1029 |
+ |
System.setSecurityManager(null); |
1030 |
+ |
} catch (SecurityException giveUp) { |
1031 |
+ |
return; |
1032 |
+ |
} |
1033 |
+ |
} |
1034 |
+ |
|
1035 |
|
ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); |
1036 |
|
System.err.println("------ stacktrace dump start ------"); |
1037 |
|
for (ThreadInfo info : threadMXBean.dumpAllThreads(true, true)) { |
1038 |
< |
String name = info.getThreadName(); |
1038 |
> |
final String name = info.getThreadName(); |
1039 |
> |
String lockName; |
1040 |
|
if ("Signal Dispatcher".equals(name)) |
1041 |
|
continue; |
1042 |
|
if ("Reference Handler".equals(name) |
1043 |
< |
&& info.getLockName().startsWith("java.lang.ref.Reference$Lock")) |
1043 |
> |
&& (lockName = info.getLockName()) != null |
1044 |
> |
&& lockName.startsWith("java.lang.ref.Reference$Lock")) |
1045 |
|
continue; |
1046 |
|
if ("Finalizer".equals(name) |
1047 |
< |
&& info.getLockName().startsWith("java.lang.ref.ReferenceQueue$Lock")) |
1047 |
> |
&& (lockName = info.getLockName()) != null |
1048 |
> |
&& lockName.startsWith("java.lang.ref.ReferenceQueue$Lock")) |
1049 |
|
continue; |
1050 |
|
if ("checkForWedgedTest".equals(name)) |
1051 |
|
continue; |
1052 |
|
System.err.print(info); |
1053 |
|
} |
1054 |
|
System.err.println("------ stacktrace dump end ------"); |
1055 |
+ |
|
1056 |
+ |
if (sm != null) System.setSecurityManager(sm); |
1057 |
|
} |
1058 |
|
|
1059 |
|
/** |
1240 |
|
} |
1241 |
|
public void refresh() {} |
1242 |
|
public String toString() { |
1243 |
< |
List<Permission> ps = new ArrayList<Permission>(); |
1243 |
> |
List<Permission> ps = new ArrayList<>(); |
1244 |
|
for (Enumeration<Permission> e = perms.elements(); e.hasMoreElements();) |
1245 |
|
ps.add(e.nextElement()); |
1246 |
|
return "AdjustablePolicy with permissions " + ps; |
1270 |
|
* Sleeps until the given time has elapsed. |
1271 |
|
* Throws AssertionFailedError if interrupted. |
1272 |
|
*/ |
1273 |
< |
void sleep(long millis) { |
1273 |
> |
static void sleep(long millis) { |
1274 |
|
try { |
1275 |
|
delay(millis); |
1276 |
|
} catch (InterruptedException fail) { |
1286 |
|
* thread to enter a wait state: BLOCKED, WAITING, or TIMED_WAITING. |
1287 |
|
*/ |
1288 |
|
void waitForThreadToEnterWaitState(Thread thread, long timeoutMillis) { |
1289 |
< |
long startTime = System.nanoTime(); |
1289 |
> |
long startTime = 0L; |
1290 |
|
for (;;) { |
1291 |
|
Thread.State s = thread.getState(); |
1292 |
|
if (s == Thread.State.BLOCKED || |
1295 |
|
return; |
1296 |
|
else if (s == Thread.State.TERMINATED) |
1297 |
|
fail("Unexpected thread termination"); |
1298 |
+ |
else if (startTime == 0L) |
1299 |
+ |
startTime = System.nanoTime(); |
1300 |
|
else if (millisElapsedSince(startTime) > timeoutMillis) { |
1301 |
|
threadAssertTrue(thread.isAlive()); |
1302 |
< |
return; |
1302 |
> |
fail("timed out waiting for thread to enter wait state"); |
1303 |
|
} |
1304 |
|
Thread.yield(); |
1305 |
|
} |
1306 |
|
} |
1307 |
|
|
1308 |
|
/** |
1309 |
< |
* Waits up to LONG_DELAY_MS for the given thread to enter a wait |
1310 |
< |
* state: BLOCKED, WAITING, or TIMED_WAITING. |
1309 |
> |
* Spin-waits up to the specified number of milliseconds for the given |
1310 |
> |
* thread to enter a wait state: BLOCKED, WAITING, or TIMED_WAITING, |
1311 |
> |
* and additionally satisfy the given condition. |
1312 |
> |
*/ |
1313 |
> |
void waitForThreadToEnterWaitState( |
1314 |
> |
Thread thread, long timeoutMillis, Callable<Boolean> waitingForGodot) { |
1315 |
> |
long startTime = 0L; |
1316 |
> |
for (;;) { |
1317 |
> |
Thread.State s = thread.getState(); |
1318 |
> |
if (s == Thread.State.BLOCKED || |
1319 |
> |
s == Thread.State.WAITING || |
1320 |
> |
s == Thread.State.TIMED_WAITING) { |
1321 |
> |
try { |
1322 |
> |
if (waitingForGodot.call()) |
1323 |
> |
return; |
1324 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
1325 |
> |
} |
1326 |
> |
else if (s == Thread.State.TERMINATED) |
1327 |
> |
fail("Unexpected thread termination"); |
1328 |
> |
else if (startTime == 0L) |
1329 |
> |
startTime = System.nanoTime(); |
1330 |
> |
else if (millisElapsedSince(startTime) > timeoutMillis) { |
1331 |
> |
threadAssertTrue(thread.isAlive()); |
1332 |
> |
fail("timed out waiting for thread to enter wait state"); |
1333 |
> |
} |
1334 |
> |
Thread.yield(); |
1335 |
> |
} |
1336 |
> |
} |
1337 |
> |
|
1338 |
> |
/** |
1339 |
> |
* Spin-waits up to LONG_DELAY_MS milliseconds for the given thread to |
1340 |
> |
* enter a wait state: BLOCKED, WAITING, or TIMED_WAITING. |
1341 |
|
*/ |
1342 |
|
void waitForThreadToEnterWaitState(Thread thread) { |
1343 |
|
waitForThreadToEnterWaitState(thread, LONG_DELAY_MS); |
1344 |
|
} |
1345 |
|
|
1346 |
|
/** |
1347 |
+ |
* Spin-waits up to LONG_DELAY_MS milliseconds for the given thread to |
1348 |
+ |
* enter a wait state: BLOCKED, WAITING, or TIMED_WAITING, |
1349 |
+ |
* and additionally satisfy the given condition. |
1350 |
+ |
*/ |
1351 |
+ |
void waitForThreadToEnterWaitState( |
1352 |
+ |
Thread thread, Callable<Boolean> waitingForGodot) { |
1353 |
+ |
waitForThreadToEnterWaitState(thread, LONG_DELAY_MS, waitingForGodot); |
1354 |
+ |
} |
1355 |
+ |
|
1356 |
+ |
/** |
1357 |
|
* Returns the number of milliseconds since time given by |
1358 |
|
* startNanoTime, which must have been previously returned from a |
1359 |
|
* call to {@link System#nanoTime()}. |
1581 |
|
return new LatchAwaiter(latch); |
1582 |
|
} |
1583 |
|
|
1584 |
< |
public void await(CountDownLatch latch) { |
1584 |
> |
public void await(CountDownLatch latch, long timeoutMillis) { |
1585 |
|
try { |
1586 |
< |
if (!latch.await(LONG_DELAY_MS, MILLISECONDS)) |
1586 |
> |
if (!latch.await(timeoutMillis, MILLISECONDS)) |
1587 |
|
fail("timed out waiting for CountDownLatch for " |
1588 |
< |
+ (LONG_DELAY_MS/1000) + " sec"); |
1588 |
> |
+ (timeoutMillis/1000) + " sec"); |
1589 |
|
} catch (Throwable fail) { |
1590 |
|
threadUnexpectedException(fail); |
1591 |
|
} |
1592 |
|
} |
1593 |
|
|
1594 |
+ |
public void await(CountDownLatch latch) { |
1595 |
+ |
await(latch, LONG_DELAY_MS); |
1596 |
+ |
} |
1597 |
+ |
|
1598 |
|
public void await(Semaphore semaphore) { |
1599 |
|
try { |
1600 |
|
if (!semaphore.tryAcquire(LONG_DELAY_MS, MILLISECONDS)) |
1829 |
|
* A CyclicBarrier that uses timed await and fails with |
1830 |
|
* AssertionFailedErrors instead of throwing checked exceptions. |
1831 |
|
*/ |
1832 |
< |
public class CheckedBarrier extends CyclicBarrier { |
1832 |
> |
public static class CheckedBarrier extends CyclicBarrier { |
1833 |
|
public CheckedBarrier(int parties) { super(parties); } |
1834 |
|
|
1835 |
|
public int await() { |
1893 |
|
} |
1894 |
|
} |
1895 |
|
|
1896 |
+ |
void assertImmutable(final Object o) { |
1897 |
+ |
if (o instanceof Collection) { |
1898 |
+ |
assertThrows( |
1899 |
+ |
UnsupportedOperationException.class, |
1900 |
+ |
new Runnable() { public void run() { |
1901 |
+ |
((Collection) o).add(null);}}); |
1902 |
+ |
} |
1903 |
+ |
} |
1904 |
+ |
|
1905 |
|
@SuppressWarnings("unchecked") |
1906 |
|
<T> T serialClone(T o) { |
1907 |
|
try { |
1908 |
|
ObjectInputStream ois = new ObjectInputStream |
1909 |
|
(new ByteArrayInputStream(serialBytes(o))); |
1910 |
|
T clone = (T) ois.readObject(); |
1911 |
+ |
if (o == clone) assertImmutable(o); |
1912 |
|
assertSame(o.getClass(), clone.getClass()); |
1913 |
|
return clone; |
1914 |
|
} catch (Throwable fail) { |
1917 |
|
} |
1918 |
|
} |
1919 |
|
|
1920 |
+ |
/** |
1921 |
+ |
* A version of serialClone that leaves error handling (for |
1922 |
+ |
* e.g. NotSerializableException) up to the caller. |
1923 |
+ |
*/ |
1924 |
+ |
@SuppressWarnings("unchecked") |
1925 |
+ |
<T> T serialClonePossiblyFailing(T o) |
1926 |
+ |
throws ReflectiveOperationException, java.io.IOException { |
1927 |
+ |
ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
1928 |
+ |
ObjectOutputStream oos = new ObjectOutputStream(bos); |
1929 |
+ |
oos.writeObject(o); |
1930 |
+ |
oos.flush(); |
1931 |
+ |
oos.close(); |
1932 |
+ |
ObjectInputStream ois = new ObjectInputStream |
1933 |
+ |
(new ByteArrayInputStream(bos.toByteArray())); |
1934 |
+ |
T clone = (T) ois.readObject(); |
1935 |
+ |
if (o == clone) assertImmutable(o); |
1936 |
+ |
assertSame(o.getClass(), clone.getClass()); |
1937 |
+ |
return clone; |
1938 |
+ |
} |
1939 |
+ |
|
1940 |
+ |
/** |
1941 |
+ |
* If o implements Cloneable and has a public clone method, |
1942 |
+ |
* returns a clone of o, else null. |
1943 |
+ |
*/ |
1944 |
+ |
@SuppressWarnings("unchecked") |
1945 |
+ |
<T> T cloneableClone(T o) { |
1946 |
+ |
if (!(o instanceof Cloneable)) return null; |
1947 |
+ |
final T clone; |
1948 |
+ |
try { |
1949 |
+ |
clone = (T) o.getClass().getMethod("clone").invoke(o); |
1950 |
+ |
} catch (NoSuchMethodException ok) { |
1951 |
+ |
return null; |
1952 |
+ |
} catch (ReflectiveOperationException unexpected) { |
1953 |
+ |
throw new Error(unexpected); |
1954 |
+ |
} |
1955 |
+ |
assertNotSame(o, clone); // not 100% guaranteed by spec |
1956 |
+ |
assertSame(o.getClass(), clone.getClass()); |
1957 |
+ |
return clone; |
1958 |
+ |
} |
1959 |
+ |
|
1960 |
|
public void assertThrows(Class<? extends Throwable> expectedExceptionClass, |
1961 |
|
Runnable... throwingActions) { |
1962 |
|
for (Runnable throwingAction : throwingActions) { |
1985 |
|
} catch (NoSuchElementException success) {} |
1986 |
|
assertFalse(it.hasNext()); |
1987 |
|
} |
1988 |
+ |
|
1989 |
+ |
public <T> Callable<T> callableThrowing(final Exception ex) { |
1990 |
+ |
return new Callable<T>() { public T call() throws Exception { throw ex; }}; |
1991 |
+ |
} |
1992 |
+ |
|
1993 |
+ |
public Runnable runnableThrowing(final RuntimeException ex) { |
1994 |
+ |
return new Runnable() { public void run() { throw ex; }}; |
1995 |
+ |
} |
1996 |
+ |
|
1997 |
+ |
/** A reusable thread pool to be shared by tests. */ |
1998 |
+ |
static final ExecutorService cachedThreadPool = |
1999 |
+ |
new ThreadPoolExecutor(0, Integer.MAX_VALUE, |
2000 |
+ |
1000L, MILLISECONDS, |
2001 |
+ |
new SynchronousQueue<Runnable>()); |
2002 |
+ |
|
2003 |
+ |
static <T> void shuffle(T[] array) { |
2004 |
+ |
Collections.shuffle(Arrays.asList(array), ThreadLocalRandom.current()); |
2005 |
+ |
} |
2006 |
|
} |