question: public static void runConcurrently ( final Callable < Void > task , final int times ) throws Exception { final ExecutorService service = Executors . newFixedThreadPool ( 5 ) ; final List < Future < ? > > futures = new ArrayList < Future < ? > > ( ) ; for ( int i = 0 ; i < times ; i ++ ) { futures . add ( service . submit ( task ) ) ; } for ( final Future < ? > future : futures ) { future . get ( ) ; } }
target:  Runs a task concurrently. Allows to test thread-safe behavior.