Semaphore vs. Monitors – what’s the difference?
What are the major differences between a Monitor and a Semaphore? 7 Answers 7
What are the major differences between a Monitor and a Semaphore? 7 Answers 7
A semaphore is a programming concept that is frequently used to solve multi-threading problems. My question to the community: What is a semaphore and how do you use it? 15 Answers 15
I’ve heard these words related to concurrent programming, but what’s the difference between lock, mutex and semaphore? 10 s 10 A lock allows only one thread to enter the part that’s locked and the lock is not shared with any other processes. A mutex is the same as a lock but it can be system … Read more
Is there any difference between a binary semaphore and mutex or are they essentially the same? 36 s 36
See this page: http://www.oracle.com/technetwork/articles/javase/index-140767.html It has a slightly different pattern which is (I think) what you are looking for: try { mutex.acquire(); try { // do something } finally { mutex.release(); } } catch(InterruptedException ie) { // … } In this usage, you’re only calling release() after a successful acquire()