My question is strongly related to this one here. As was posted there, I would like the main thread to wait until the work queue is empty and all tasks have finished. The pr
Why don't you use a counter? For example:
private AtomicInteger counter = new AtomicInteger(0);
and increment the counter by one just before submitting the task to the queue:
counter.incrementAndGet();
and decrement it by one at the end of the task:
counter.decrementAndGet();
and the check would be something like:
// ...
while (counter.get() > 0);