...

/

Java's Monitor & Hoare vs Mesa Monitors

Java's Monitor & Hoare vs Mesa Monitors

Continues the discussion of the differences between a mutex and a monitor and also looks at Java's implementation of the monitor.

We discussed the abstract concept of a monitor in the previous section and now let's see the working of a concrete implementation of it in Java.

Java’s Monitor

In Java every object is a condition variable and has an associated lock that is hidden from the developer. Each java object exposes wait() and notify() methods.

Before we execute wait() on a java object we need to lock its hidden mutex. That is done implicitly through the synchronized keyword. If you attempt to call wait() or ...