Thanks Jeff.
After using the CountDownLatch, it is working as expected atleast with the initial test with no null exceptions. Is this the correct way to use CountDownLatch. Also, i see their is one more way to do this by using Semaphore, with the release() and acquire() , what is the difference between them ..
Secondly i don't understand how the Semaphore works at all , i mean where is the link which holds the threads to wait .. it say's it's just a counter adding the permits when release() is called
Thanks in advance.