[concurrency-interest] binary semaphore

Michele Mazzucco michele.mazzucco at ncl.ac.uk
Mon Sep 19 08:54:58 EDT 2005


Java APIs say "A semaphore initialized to one, and which is used such 
that it only has at most one permit available, can serve as a mutual 
exclusion lock" (binary semaphore)
(http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Semaphore.html)

How can I implement a binary semaphore in a bounded buffer environment, 
say of capacity of one element (the binary semaphore has the property  - 
unlike many Lock implementations - that the "lock" can be released by a 
thread other than the owner), without using synchronized methods and 
wait() and notify()/notifyAll() calls?


More information about the Concurrency-interest mailing list