jdk/test/java/util/concurrent/FutureTask/BlockingTaskExecutor.java
changeset 34347 4a17f9e90a0f
parent 14342 8435a30053c1
child 43522 f9c6f543c4db
equal deleted inserted replaced
34346:09f5f3df8fa8 34347:4a17f9e90a0f
    26  * @bug 6431315
    26  * @bug 6431315
    27  * @summary ExecutorService.invokeAll might hang
    27  * @summary ExecutorService.invokeAll might hang
    28  * @author Martin Buchholz
    28  * @author Martin Buchholz
    29  */
    29  */
    30 
    30 
    31 import java.util.*;
    31 import java.util.ArrayList;
    32 import java.util.concurrent.*;
    32 import java.util.Collection;
       
    33 import java.util.concurrent.Callable;
       
    34 import java.util.concurrent.ExecutorService;
       
    35 import java.util.concurrent.Executors;
       
    36 import java.util.concurrent.RejectedExecutionException;
       
    37 import java.util.concurrent.TimeUnit;
    33 
    38 
    34 /**
    39 /**
    35  * Adapted from Doug Lea, which was...
    40  * Adapted from Doug Lea, which was...
    36  * adapted from a posting by Tom Sugden tom at epcc.ed.ac.uk
    41  * adapted from a posting by Tom Sugden tom at epcc.ed.ac.uk
    37  */
    42  */
    69 
    74 
    70         // Now try to shutdown the executor service while tasks
    75         // Now try to shutdown the executor service while tasks
    71         // are blocked.  This should cause the tasks to be
    76         // are blocked.  This should cause the tasks to be
    72         // interrupted.
    77         // interrupted.
    73         executor.shutdownNow();
    78         executor.shutdownNow();
    74         if (! executor.awaitTermination(5, TimeUnit.SECONDS))
    79         if (! executor.awaitTermination(5L, TimeUnit.SECONDS))
    75             throw new Error("Executor stuck");
    80             throw new Error("Executor stuck");
    76 
    81 
    77         // Wait for the invocation thread to complete.
    82         // Wait for the invocation thread to complete.
    78         thread.join(5000);
    83         thread.join(5000);
    79         if (thread.isAlive()) {
    84         if (thread.isAlive()) {