Java Monitor

Java Monitor (classic reader-writer problem) 1 writer & 2 readers

JavaMultithreadMonitor

 

The writer fills data until the buffer is full. If the buffer is full (condition variable), then waits. Otherwise (i.e., the buffer is available), it fills data in the buffer. After that, it signals.

The reader reads data until the buffer is empty. If the buffer is empty (condition variable), then wait. Otherwise (i.e., the buffer is available), it reads data. After that, it signals.