Compile and run the program for a short moment, and you will see the following History Graph window:
This window shows that the main thread created eight threads IncThread1, DecThread1, DecThread2, IncThread2, DecThread3, IncThread4, IncThread5 and IncThread3. As shown by the MB tags, all eight threads called a monitor procedure. However, due to the mutual exclusion requirement of a monitor, only one thread can be executing in a monitor. The above shows that thread IncThread1 is running in the monitor because of the MA tag. All other seven threads are blocked outside of the monitor. The following snapshot of the main window confirms this finding:
It shows that thread IncThread1 is in monitor CounterMonitor, and there are seven other threads (see column WOut) blocked outside. Click on the monitor name CounterMonitor in the display area of the main window to bring up its Monitor window as shown below:
This window provides all vital information of monitor CounterMonitor. It shows that the active thread is IncThread1, the waiting threads are DecThread1, DecThread2, IncThread2, DecThread3, IncThread4, IncThread5 and IncThread3, and the monitor type HOARE.
If one lets the program run and watch the History Graph carefully, one can reconstruct the program activities with the help of the information shown in the main window and the Monitor window. To get more information between exiting and entering a monitor, do not forget to click on the Monitor in the Monitor window. The following is a snapshot of running the program a little longer.
The history bars show that IncThread1 enters and exits the monitor. When it exits (i.e., a ME tag), the monitor becomes empty and thread enters (i.e., a line connecting a ME tag of thread IncThread1 and a MA tag of thread DecThread1). Then, when thread DecThread1 exits, thread DecThread2 enters, and when thread DecThread2 exits, IncThread2 enters. This will continue until the program ends.