it makes the thread communication and synchronization more sophisticated than traditional
if u want all threads to be started after one thread completed
or
if u want one thread to be started , after all threads completed
or
if u want one thread to be started , after some task completed by certain number of times
in all the above cases we can use CountdownLatch
in all the above cases we have Thread Communications and Synchronizations
lets see how we can use this CountDownLatch , finally a class under the java api from 1.5 version like below
if u want all threads to be started after one thread completed
or
if u want one thread to be started , after all threads completed
or
if u want one thread to be started , after some task completed by certain number of times
in all the above cases we can use CountdownLatch
in all the above cases we have Thread Communications and Synchronizations
lets see how we can use this CountDownLatch , finally a class under the java api from 1.5 version like below
java.lang.Object java.util.concurrent.CountDownLatch
lets consider a case where one main thread has to complete one task , then only remaining thread can start there execution.
u can consider the producer and consumer problem
here producer who writes some data into the variable and
consumers will all are waiting for that variable to be filled by the producer, in such case this CountDownlatch will be very useful
No comments:
Post a Comment