[concurrency-interest] difference latch and lock

Peter Veentjer alarmnummer at gmail.com
Fri Sep 1 01:43:51 EDT 2006

Thanks for your answer Brian. Could you give an example how a Latch
would be used?

On 8/31/06, Brian Goetz <brian at quiotix.com> wrote:
> Latches and locks are different.  It is easiest to think of them in
> terms of their state machines.  A lock goes from unlocked to locked and
> back to unlocked with the right sequence of lock and unlock operations.
>  A latch goes from closed to open after some sequence of state
> transitions, and NEVER GOES BACK.  Once it transitions to the terminal
> state, it never changes.
> Both offer blocking behavior.  For Lock, if you try to acquire an
> already-held lock, you block until the lock is available.  For Latch, if
> you try to wait for the latch, you block until someone else puts the
> latch in the terminal (open) state.

More information about the Concurrency-interest mailing list