Here we are taking a lock on Node object "f" and performing some update operation in synchronised way.
Could someone please let me know, how we can convert this code using ReentrantLock?
I read we can take a lock on block of code using lock() and unlock() methods but not see anywhere how we can take a lock on object.
public void updateNodeValue(){
Node<K,V> f = getNode();
synchronized (f) {
// do something here to update the value in Node Object f
}
}
public Node<K,V> getNode(){
// return NodeObject from an Array
}