ExecutorService, how to wait for all tasks to finish?

The simplest approach is to use ExecutorService.invokeAll() which does what you want in a one-liner. In your parlance, you'll need to modify or wrap ComputeDTask to implement Callable which can give you quite a bit more flexibility. Probably in your app there is a meaningful implementation of Callable.call() but here's a way to wrap it if not using Executors.callable() .

If you want to wait for all tasks to complete, use the shutdown method instead of wait. Then follow it with awaitTermination.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions