Synchronization question
Lee Ming
wonderer_101 at live.com
Tue Dec 20 22:32:12 PST 2011
Hi everyone,
Currently We are developing a system that requires a lot of usages of Java concurrency. There seem to be some
concurrent bugs in our system. Thus I just wonder about the following usage of lock
class Test{
private final PInfo obj = new PInfo();
private ReentrantLock lock = new ReentrantLock();
...
public void put(long n){
try{
lock.lock();
obj.put(n);
}
finally { lock.unlock();}
}
}
The question is: does the lock.lock() statement will guarantee that subsequent methods stacks
which involved with obj.put(n) will be synchronized ? that is to say, the fields of the object obj
will be read/write directly from main memory and never cache.
Thank you and regards
Bhm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20111221/08a7eef3/attachment.html
More information about the serviceability-dev
mailing list