Originally posted by Mathew Sam:
In the LockManager class i have only two synchronized methods.Do I need to sychronize the access to the HashMap like
synchronized(locks) { }
class LockManager {
private HashMap locks = new HashMap();
pubilc synchronized void lock (){
// Access HashMap
}
pubilc synchronized void unlock (){
// Access HashMap
}
}
You don't have to synchronized on hashmap if u r synchronizing on methods. You synchronize on either methods or hashmap but avoid on both.