[concurrency-interest] The semantics of reentrant lock
Nader Aeinehchi
nader at aeinehchi.com
Wed Jan 18 08:20:40 EST 2012
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.
More information about the Concurrency-interest
mailing list