This week's book giveaway is in the Spring forum. We're giving away four copies of Java Persistence with Spring Data and Hibernate and have Cătălin Tudose on-line! See this thread for details.
hello ranchies, can anybody plz explain me, what is class lock?...how it is different from object lock......
i read that when we make instance method synchronized then by calling to this method we get the object lock and no other object have acces to other synchronized method.....
So my question is what happens when we call static synchronized method.....?
i read that we get the class lock...so what is that actually...?
There is no such thing as a "class lock". All locks are on object instances. What happens when you call a synchronized static method of a class? When the class gets loaded, an object of the class Class is created. A lock is obtained on this (disregarding classloader issues) uniqueClass object.
You could, I suppose, refer to the above mentioned lock as the "class lock", but is really a normal lock on an object. [ November 15, 2005: Message edited by: Barry Gaunt ]