Java Reference
In-Depth Information
main thread is waiting
}
catch (InterruptedException ie)
{
System.err.println(ie);
}
}
void report(String s)
{
Sys-
tem.out.println(System.currentTimeMillis()+": "+
Thread.currentThread()+":
"+s);
}
};
ExecutorService
executor
=
Execut-
ors.newFixedThreadPool(NTHREADS);
for (int i = 0; i < NTHREADS; i++)
executor.execute(r);
try
{
System.out.println("main
thread
doing
something");
Thread.sleep(1000); // sleep for 1 second
startSignal.countDown(); // let all threads pro-
ceed
System.out.println("main thread doing something
else");
doneSignal.await();
// wait for all threads
to finish
executor.shutdownNow();
}
catch (InterruptedException ie)
{
System.err.println(ie);
}
Search WWH ::




Custom Search