I am using a method from a class, which has been written by someone else…
Part of the method is synchronized. However, the part within the synchronized portion does the actual job for which the method has been called.
The block has been synchronized on ‘this’. However, as many times I call the method, the executing
thread fails to acquire lock for the block.
Question I : If I synchronize on ‘this’, does this mean that any other method in that class, which changes the instance variables, called from somewhere else, will fail or succeed?
Question II : If I synchronize on anything else, does that mean I will get the same result in all conditions as it was by synchronized on ‘this’? Actually, what difference it makes if synchronized on ‘this’ else synchronized on any third party object?