[concurrency-interest] The semantics of reentrant lock

√iktor Ҡlang viktor.klang at gmail.com
Wed Jan 18 08:30:28 EST 2012


Docs are a wonderful thing:
http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/locks/ReentrantLock.html#unlock%28%29

On Wed, Jan 18, 2012 at 2:20 PM, Nader Aeinehchi <nader at aeinehchi.com>wrote:

> Hi
>
> Forgive me for my ignorance, but I cannot be 100% sure from reading
> JavaDoc documentation whether java.util.concurrency.**ReentrantLock has
> the same semantics as the intrinsic lock.  Is it so that lock.unlock() does
> not have any effect once method2 is called from method1?
>
> class Foo{
>
> private final Lock lock = new ReentrantLock();
>
> public void method1(){
>    lock.lock();
>    try{
>        //calls method2
>        method2();
>    }finally{
>        lock.unlock();
>    }
> }
>
> public void method2(){
>    lock.lock();
>    try{
>        //do something
>    }finally{
>        lock.unlock();
>    }
> }
>
> }
>
> Thanks.
> ______________________________**_________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.**oswego.edu <Concurrency-interest at cs.oswego.edu>
> http://cs.oswego.edu/mailman/**listinfo/concurrency-interest<http://cs.oswego.edu/mailman/listinfo/concurrency-interest>
>



-- 
Viktor Klang

Akka Tech Lead
Typesafe <http://www.typesafe.com/> - The software stack for applications
that scale

Twitter: @viktorklang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20120118/505468ab/attachment.html>


More information about the Concurrency-interest mailing list