public static < T > Collection < SyncThread < T > > getCompletedThreads ( int num , Callable < T > callable ) throws InterruptedException { Collection < SyncThread < T >> rv = new ArrayList < SyncThread < T > > ( num ) ; CyclicBarrier barrier = new CyclicBarrier ( num ) ; for ( int i = 0 ; i < num ; i ++ ) { rv . add ( new SyncThread < T > ( barrier , callable ) ) ; } for ( SyncThread < T > t : rv ) { t . join ( ) ; } return rv ; }
Get a collection of SyncThreads that all began as close to the same time as possible and have all completed .