What is the difference between synchronizing a static method and a non static method in java?Can anybody please explain with an example. Also is there any difference in sync
There is virtually no difference between synchronizing a block and synchronizing a method. Basically:
void synchronized m() {...}
is the same as
void m() { synchronized(this) {...} }
By comparison a static synchronized method is the same as:
static void m() { synchronized(MyClass.class) {...} }