This question is based on Synchronizing on an Integer results in NullPointerException and originated from this question Synchronizing on an Integer value
I wanted to know what is the best way to increase number of locks in Java. Other than which is implemented in ConcurrentHashMap
i.e. Based on Fixed array and by calculating hash of key to refer index of array?
Below is what is expected.
If doMoreThing()
for one object is in process then I should not do doAnotherThing()
for the same object if it called from different thread.
public void doSomething(int i) {
doAnotherThing(i);// some checks here based on it it will call to
// doMoreThing
doMoreThing(i);
}