How Synchronization works in Java?
Synchronization in java is done through aquiering the monitor on some specific Object. Therefore, if you do this: class TestClass { SomeClass someVariable; public void myMethod () { synchronized (someVariable) { … } } public void myOtherMethod() { synchronized (someVariable) { … } } } Then those two blocks will be protected by execution of … Read more