ContactUs :

Please send your Questions & Answers or Feedback to "mohan@javabook.org"

Explain semaphore and monitors in java threading.

A semaphore is a flag variable used to check whether a resource is currently being used by another thread or process.

The drawback of semaphores is that there is no control or guarantee of proper usage.

A Monitor defines a lock and condition variables for managing concurrent access to shared data. The monitor uses the lock to ensure that only a single thread is active in the monitor code at any time.

A semaphore is a generalization of a monitor. A monitor allows only one thread to lock an object at once.

 

Related Posts Plugin for WordPress, Blogger...
Flag Counter