How it works...

We can see that thread 4 gained exclusive access to the contended resource. At the same time, thread 3 and thread 5 tried to access the contended resource locked by thread 4. This then caused the other two threads to wait until thread 4 had completed and released the lock. The result of this is that the code is executed in an orderly manner, as can be seen in the console window output. Each thread waits its turn until it can access the resource and lock its thread.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.189.67