, , . A ThreadPoolExecutor (an ExecutorService -implementation) BlockingQueue , . , ThreadPoolExecutor.
private BlockingQueue<Runnable> queue;
...
ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 10, new Long(1000),
TimeUnit.MILLISECONDS, this.queue);
, . , ( , ?)
if (issuedThreads == pool.getCompletedTaskCount()) {
pool.shutdown();
}
, . :
try {
while (!this.pool.awaitTermination(1000, TimeUnit.MILLISECONDS));
} catch (InterruptedException e) {