can any one explain the statement ..."static synchronized method and non static synchronized method will not block each other -they can run at the same time"
See Question&Answers more detail:oscan any one explain the statement ..."static synchronized method and non static synchronized method will not block each other -they can run at the same time"
See Question&Answers more detail:osstatic synchronized void test() { foo(); }
equals
static void test() { synchronized(MyClass.class) { foo(); } }
while
synchronized void test() { foo(); }
equals
void test() { synchronized(this) { foo(); } }
This means: static methods lock on the class object of the class. Non-static methods lock on the instance on which they're called (by default, synchronized(anyOtherLock)
is also possible). Since they lock on different objects, they don't block each other.