660 |
|
q); |
661 |
|
try (PoolCleaner cleaner = cleaner(p, done)) { |
662 |
|
final CountDownLatch threadStarted = new CountDownLatch(1); |
663 |
< |
FutureTask[] tasks = new FutureTask[5]; |
663 |
> |
FutureTask[] rtasks = new FutureTask[5]; |
664 |
> |
@SuppressWarnings("unchecked") |
665 |
> |
FutureTask<Boolean>[] tasks = (FutureTask<Boolean>[])rtasks; |
666 |
|
for (int i = 0; i < tasks.length; i++) { |
667 |
< |
Callable<Boolean> task = new CheckedCallable<Boolean>() { |
667 |
> |
Callable<Boolean> task = new CheckedCallable<>() { |
668 |
|
public Boolean realCall() throws InterruptedException { |
669 |
|
threadStarted.countDown(); |
670 |
|
assertSame(q, p.getQueue()); |
671 |
|
await(done); |
672 |
|
return Boolean.TRUE; |
673 |
|
}}; |
674 |
< |
tasks[i] = new FutureTask(task); |
674 |
> |
tasks[i] = new FutureTask<>(task); |
675 |
|
p.execute(tasks[i]); |
676 |
|
} |
677 |
|
await(threadStarted); |
728 |
|
LONG_DELAY_MS, MILLISECONDS, |
729 |
|
q); |
730 |
|
try (PoolCleaner cleaner = cleaner(p, done)) { |
731 |
< |
FutureTask[] tasks = new FutureTask[5]; |
731 |
> |
FutureTask[] rtasks = new FutureTask[5]; |
732 |
> |
@SuppressWarnings("unchecked") |
733 |
> |
FutureTask<Boolean>[] tasks = (FutureTask<Boolean>[])rtasks; |
734 |
|
for (int i = 0; i < tasks.length; i++) { |
735 |
< |
Callable<Boolean> task = new CheckedCallable<Boolean>() { |
735 |
> |
Callable<Boolean> task = new CheckedCallable<>() { |
736 |
|
public Boolean realCall() throws InterruptedException { |
737 |
|
threadStarted.countDown(); |
738 |
|
await(done); |
739 |
|
return Boolean.TRUE; |
740 |
|
}}; |
741 |
< |
tasks[i] = new FutureTask(task); |
741 |
> |
tasks[i] = new FutureTask<>(task); |
742 |
|
p.execute(tasks[i]); |
743 |
|
} |
744 |
|
await(threadStarted); |
773 |
|
Runnable waiter = new CheckedRunnable() { public void realRun() { |
774 |
|
threadsStarted.countDown(); |
775 |
|
try { |
776 |
< |
MILLISECONDS.sleep(2 * LONG_DELAY_MS); |
776 |
> |
MILLISECONDS.sleep(LONGER_DELAY_MS); |
777 |
|
} catch (InterruptedException success) {} |
778 |
|
ran.getAndIncrement(); |
779 |
|
}}; |
1296 |
|
public void testMaximumPoolSizeIllegalArgumentException2() { |
1297 |
|
final ThreadPoolExecutor p = |
1298 |
|
new CustomTPE(2, 3, |
1299 |
< |
LONG_DELAY_MS, |
1300 |
< |
MILLISECONDS,new ArrayBlockingQueue<Runnable>(10)); |
1299 |
> |
LONG_DELAY_MS, MILLISECONDS, |
1300 |
> |
new ArrayBlockingQueue<Runnable>(10)); |
1301 |
|
try (PoolCleaner cleaner = cleaner(p)) { |
1302 |
|
try { |
1303 |
|
p.setMaximumPoolSize(-1); |
1646 |
|
l.add(latchAwaitingStringTask(latch)); |
1647 |
|
l.add(null); |
1648 |
|
try { |
1649 |
< |
e.invokeAny(l, randomTimeout(), MILLISECONDS); |
1649 |
> |
e.invokeAny(l, randomTimeout(), randomTimeUnit()); |
1650 |
|
shouldThrow(); |
1651 |
|
} catch (NullPointerException success) {} |
1652 |
|
latch.countDown(); |
1813 |
|
public void testTimedInvokeAll6() throws Exception { |
1814 |
|
for (long timeout = timeoutMillis();;) { |
1815 |
|
final CountDownLatch done = new CountDownLatch(1); |
1816 |
< |
final Callable<String> waiter = new CheckedCallable<String>() { |
1816 |
> |
final Callable<String> waiter = new CheckedCallable<>() { |
1817 |
|
public String realCall() { |
1818 |
|
try { done.await(LONG_DELAY_MS, MILLISECONDS); } |
1819 |
|
catch (InterruptedException ok) {} |
1832 |
|
p.invokeAll(tasks, timeout, MILLISECONDS); |
1833 |
|
assertEquals(tasks.size(), futures.size()); |
1834 |
|
assertTrue(millisElapsedSince(startTime) >= timeout); |
1835 |
< |
for (Future future : futures) |
1835 |
> |
for (Future<?> future : futures) |
1836 |
|
assertTrue(future.isDone()); |
1837 |
|
assertTrue(futures.get(1).isCancelled()); |
1838 |
|
try { |
1970 |
|
} |
1971 |
|
} |
1972 |
|
} |
1973 |
+ |
@SuppressWarnings("removal") |
1974 |
+ |
public void testFinalizeMethodCallsSuperFinalize() { |
1975 |
+ |
new CustomTPE(1, 1, |
1976 |
+ |
LONG_DELAY_MS, MILLISECONDS, |
1977 |
+ |
new LinkedBlockingQueue<Runnable>()) { |
1978 |
+ |
|
1979 |
+ |
/** |
1980 |
+ |
* A finalize method without "throws Throwable", that |
1981 |
+ |
* calls super.finalize(). |
1982 |
+ |
*/ |
1983 |
+ |
protected void finalize() { |
1984 |
+ |
super.finalize(); |
1985 |
+ |
} |
1986 |
+ |
}.shutdown(); |
1987 |
+ |
} |
1988 |
|
|
1989 |
|
} |