What is java's equivalent of ManualResetEvent?

.net, java, multithreading, synchronization

Solution

The closest I know of is the Semaphore. Just use it with a "permit" count of 1, and acquire/release will be pretty much the same as what you know from the `ManualResetEvent`.

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. This is more commonly known as a binary semaphore, because it only has two states: one permit available, or zero permits available. When used in this way, the binary semaphore has the property (unlike many Lock implementations), that the "lock" can be released by a thread other than the owner (as semaphores have no notion of ownership). This can be useful in some specialized contexts, such as deadlock recovery.

Problem

What is java's equivalent of ManualResetEvent?

Original source

Related problems