private static void par_ief ( CompList < ? > t , int numproc ) throws Exception { if ( numproc < 1 ) { throw new IllegalArgumentException ( "numproc" ) ; } final CountDownLatch latch = new CountDownLatch ( t . list ( ) . size ( ) ) ; // final ExecutorService e = Executors.newFixedThreadPool(numproc); for ( final Compound c : t ) { e . submit ( new Runnable ( ) { @ Override public void run ( ) { try { ComponentAccess . callAnnotated ( c , Initialize . class , true ) ; c . execute ( ) ; ComponentAccess . callAnnotated ( c , Finalize . class , true ) ; } catch ( Throwable E ) { e . shutdownNow ( ) ; } latch . countDown ( ) ; } } ) ; } latch . await ( ) ; // e.shutdown(); }
Runs a set of Compounds in parallel . there are always numproc + 1 threads active .