[concurrency-interest] difference latch and lock
Brian Goetz
brian at quiotix.com
Mon Sep 4 13:09:41 EDT 2006
See JCiP 5.5.1 and 5.5.2. Also 8.5.1 and 14.2.5 for more examples.
Peter Veentjer wrote:
> 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.
>>
>>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at altair.cs.oswego.edu
> http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
More information about the Concurrency-interest
mailing list