Difference between traditional synchronization and Condition interface in java



What is Condition interface?
java.util.concurrent.locks.Condition interface  is found in java.util.concurrent.locks package. Condition instance are similar to using Wait(), notify() and notifyAll() methods on object.



Difference between traditional synchronization and Condition interface in java.

  • In case of traditional synchronization, there is only one object monitor so we can have only single wait-set per object. But,
Condition instance are used with Lock instance, Condition factors out the Object monitor methods ( Wait(), notify() and notifyAll()) into distinct objects to give the multiple wait-sets per object.





RELATED LINKS>

Locks and ReEntrantLocks in java


Implementation of custom/own Lock and ReEntrantLock in java


ReentrantLock class provides implementation of Lock’s newCondition() method - description and solving producer consumer program using this method


No comments:

Post a Comment