@Test public void sharedPoolStrategy() throws InterruptedException { ExecutorService sharedPool = Executors.newCachedThreadPool( DAEMON_THREAD_FACTORY ); SchedulingStrategy strategy1 = SchedulingStrategies.createParallelSharedStrategy( logger, sharedPool ); assertTrue( strategy1.hasSharedThreadPool() ); assertTrue( strategy1.canSchedule() ); SchedulingStrategy strategy2 = SchedulingStrategies.createParallelSharedStrategy( logger, sharedPool ); assertTrue( strategy2.hasSharedThreadPool() ); assertTrue( strategy2.canSchedule() ); Task task1 = new Task(); Task task2 = new Task(); Task task3 = new Task(); Task task4 = new Task(); strategy1.schedule( task1 ); strategy2.schedule( task2 ); strategy1.schedule( task3 ); strategy2.schedule( task4 ); assertTrue( strategy1.canSchedule() ); assertTrue( strategy2.canSchedule() ); assertTrue( strategy1.finished() ); assertFalse( strategy1.canSchedule() ); assertTrue( strategy2.finished() ); assertFalse( strategy2.canSchedule() ); assertTrue( task1.result ); assertTrue( task2.result ); assertTrue( task3.result ); assertTrue( task4.result ); }
public static SchedulingStrategy createParallelSharedStrategy( ConsoleStream logger, ExecutorService threadPool ) { if ( threadPool == null ) { throw new NullPointerException( "null threadPool in #createParallelSharedStrategy" ); } return new SharedThreadPoolStrategy( logger, threadPool ); }
SchedulingStrategies { public static SchedulingStrategy createParallelSharedStrategy( ConsoleStream logger, ExecutorService threadPool ) { if ( threadPool == null ) { throw new NullPointerException( "null threadPool in #createParallelSharedStrategy" ); } return new SharedThreadPoolStrategy( logger, threadPool ); } }
SchedulingStrategies { public static SchedulingStrategy createParallelSharedStrategy( ConsoleStream logger, ExecutorService threadPool ) { if ( threadPool == null ) { throw new NullPointerException( "null threadPool in #createParallelSharedStrategy" ); } return new SharedThreadPoolStrategy( logger, threadPool ); }  }
SchedulingStrategies { public static SchedulingStrategy createParallelSharedStrategy( ConsoleStream logger, ExecutorService threadPool ) { if ( threadPool == null ) { throw new NullPointerException( "null threadPool in #createParallelSharedStrategy" ); } return new SharedThreadPoolStrategy( logger, threadPool ); }  static SchedulingStrategy createInvokerStrategy( ConsoleStream logger ); static SchedulingStrategy createParallelStrategy( ConsoleStream logger, int nThreads ); static SchedulingStrategy createParallelStrategyUnbounded( ConsoleStream logger ); static SchedulingStrategy createParallelSharedStrategy( ConsoleStream logger, ExecutorService threadPool ); }
SchedulingStrategies { public static SchedulingStrategy createParallelSharedStrategy( ConsoleStream logger, ExecutorService threadPool ) { if ( threadPool == null ) { throw new NullPointerException( "null threadPool in #createParallelSharedStrategy" ); } return new SharedThreadPoolStrategy( logger, threadPool ); }  static SchedulingStrategy createInvokerStrategy( ConsoleStream logger ); static SchedulingStrategy createParallelStrategy( ConsoleStream logger, int nThreads ); static SchedulingStrategy createParallelStrategyUnbounded( ConsoleStream logger ); static SchedulingStrategy createParallelSharedStrategy( ConsoleStream logger, ExecutorService threadPool );  }