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
                                          

Reply via email to