I am studying mutual exclusion in college, and we just covered the producer/consumer problem. The class does not involve writing code, but I decided to implement a bounded buffer version of this problem. I have never written a multi-threaded program before, nor have I written a program with mutual exclusion before, so I decided to request a review here. I
I implemented three variations, a busy-waiting variation, a SemaphoreSemaphore variation, and a MonitorMonitor variation. All of these reside in a class named ProgramProgram, which is needed for the threading. The MonitorMonitor variation looks as if there should be a simpler solution with fewer variables, is. Is this so?
This is the SemaphoreSemaphore implementation:
And this is the MonitorMonitor implementation:
Any comments will be appreciated.