public static long runMultiThreaded(Iterable<Callable<?>> calls,GridTestSafeThreadFactory threadFactory) throws Exception {
  if (!busyLock.enterBusy())   throw new IllegalStateException("Failed to start new threads (test is being stopped).");
  Collection<Thread> threads=new ArrayList<>();
  long time;
  try {
    for (    Callable<?> call : calls)     threads.add(threadFactory.newThread(call));
    time=System.currentTimeMillis();
    for (    Thread t : threads)     t.start();
  }
  finally {
    busyLock.leaveBusy();
  }
  for (  Thread t : threads)   t.join();
  time=System.currentTimeMillis() - time;
  threadFactory.checkError();
  return time;
}

public static long runMultiThreaded ( Iterable < Callable < ? > > calls , GridTestSafeThreadFactory threadFactory ) throws Exception { if ( ! busyLock . enterBusy ( ) ) throw new IllegalStateException ( "Failed to start new threads (test is being stopped)." ) ; Collection < Thread > threads = new ArrayList < > ( ) ; long time ; try { for ( Callable < ? > call : calls ) threads . add ( threadFactory . newThread ( call ) ) ; time = System . currentTimeMillis ( ) ; for ( Thread t : threads ) t . start ( ) ; } finally { busyLock . leaveBusy ( ) ; } for ( Thread t : threads ) t . join ( ) ; time = System . currentTimeMillis ( ) - time ; threadFactory . checkError ( ) ; return time ; }
runs callable tasks each in separate threads .
