jdk/test/java/util/concurrent/ThreadPoolExecutor/FlakyThreadFactory.java
changeset 36233 f85ed703cf7e
parent 34347 4a17f9e90a0f
equal deleted inserted replaced
36232:7a020ad42ac0 36233:f85ed703cf7e
    33  */
    33  */
    34 
    34 
    35 /*
    35 /*
    36  * @test
    36  * @test
    37  * @summary Should be able to shutdown a pool when worker creation failed.
    37  * @summary Should be able to shutdown a pool when worker creation failed.
       
    38  * @library /lib/testlibrary/
    38  */
    39  */
       
    40 
       
    41 import static java.util.concurrent.TimeUnit.MILLISECONDS;
    39 
    42 
    40 import java.util.concurrent.LinkedBlockingQueue;
    43 import java.util.concurrent.LinkedBlockingQueue;
    41 import java.util.concurrent.ThreadFactory;
    44 import java.util.concurrent.ThreadFactory;
    42 import java.util.concurrent.ThreadPoolExecutor;
    45 import java.util.concurrent.ThreadPoolExecutor;
    43 import java.util.concurrent.TimeUnit;
    46 import java.util.concurrent.TimeUnit;
       
    47 import jdk.testlibrary.Utils;
    44 
    48 
    45 public class FlakyThreadFactory {
    49 public class FlakyThreadFactory {
       
    50     static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
       
    51 
    46     void test(String[] args) throws Throwable {
    52     void test(String[] args) throws Throwable {
    47         test(NullPointerException.class,
    53         test(NullPointerException.class,
    48              new ThreadFactory() {
    54              new ThreadFactory() {
    49                 public Thread newThread(Runnable r) {
    55                 public Thread newThread(Runnable r) {
    50                     throw new NullPointerException();
    56                     throw new NullPointerException();
    87         } catch (Throwable t) {
    93         } catch (Throwable t) {
    88             /* t.printStackTrace(); */
    94             /* t.printStackTrace(); */
    89             check(exceptionClass.isInstance(t));
    95             check(exceptionClass.isInstance(t));
    90         }
    96         }
    91         pool.shutdown();
    97         pool.shutdown();
    92         check(pool.awaitTermination(10L, TimeUnit.SECONDS));
    98         check(pool.awaitTermination(LONG_DELAY_MS, MILLISECONDS));
    93     }
    99     }
    94 
   100 
    95     //--------------------- Infrastructure ---------------------------
   101     //--------------------- Infrastructure ---------------------------
    96     volatile int passed = 0, failed = 0;
   102     volatile int passed = 0, failed = 0;
    97     void pass() {passed++;}
   103     void pass() {passed++;}