Suppose i have a countdown latch of size 3 i.e. 3 threads are spawned off from parent thread.
CountDownLatch latch = new CountDownLatch(3);
latch.await().
Now there will be three threads which will be calling countDown after their respective task completion.
// do something
latch.countDown();
My question is that the moment task gets completed whats the behavior of thread that was executing that task.
Does that thread gets terminated right at that moment, or waits for sometime by going into idle state. ?
I could find it anywhere on java doc of countdown latch.
It depends upon the code in the child threads. If there is more computation to do after the
CountDownLatch
it will then continue with the computation. If not, the the thread will termninate.