629 |
|
public void testTimedGet_Cancellation(final boolean mayInterruptIfRunning) { |
630 |
|
final CountDownLatch pleaseCancel = new CountDownLatch(3); |
631 |
|
final CountDownLatch cancelled = new CountDownLatch(1); |
632 |
< |
final Callable<Object> callable = |
633 |
< |
new CheckedCallable<Object>() { |
632 |
> |
final Callable<Object> callable = new CheckedCallable<>() { |
633 |
|
public Object realCall() throws InterruptedException { |
634 |
|
pleaseCancel.countDown(); |
635 |
|
if (mayInterruptIfRunning) { |
721 |
|
*/ |
722 |
|
public void testGet_Interruptible() { |
723 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
724 |
< |
final FutureTask<Object> task = new FutureTask<Object>(new NoOpCallable()); |
724 |
> |
final FutureTask<Object> task = new FutureTask<>(new NoOpCallable()); |
725 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
726 |
|
public void realRun() throws Exception { |
727 |
|
Thread.currentThread().interrupt(); |
750 |
|
*/ |
751 |
|
public void testTimedGet_Interruptible() { |
752 |
|
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
753 |
< |
final FutureTask<Object> task = new FutureTask<Object>(new NoOpCallable()); |
753 |
> |
final FutureTask<Object> task = new FutureTask<>(new NoOpCallable()); |
754 |
|
Thread t = newStartedThread(new CheckedRunnable() { |
755 |
|
public void realRun() throws Exception { |
756 |
|
Thread.currentThread().interrupt(); |
779 |
|
* A timed out timed get throws TimeoutException |
780 |
|
*/ |
781 |
|
public void testGet_TimeoutException() throws Exception { |
782 |
< |
FutureTask<Object> task = new FutureTask<Object>(new NoOpCallable()); |
782 |
> |
FutureTask<Object> task = new FutureTask<>(new NoOpCallable()); |
783 |
|
long startTime = System.nanoTime(); |
784 |
|
try { |
785 |
|
task.get(timeoutMillis(), MILLISECONDS); |
793 |
|
* timed get with null TimeUnit throws NullPointerException |
794 |
|
*/ |
795 |
|
public void testGet_NullTimeUnit() throws Exception { |
796 |
< |
FutureTask<Object> task = new FutureTask<Object>(new NoOpCallable()); |
796 |
> |
FutureTask<Object> task = new FutureTask<>(new NoOpCallable()); |
797 |
|
long[] timeouts = { Long.MIN_VALUE, 0L, Long.MAX_VALUE }; |
798 |
|
|
799 |
|
for (long timeout : timeouts) { |