jbu jbu - 1 month ago 17
Java Question

Java synchronized static methods: lock on object or class

The Java Tutorials say: "it is not possible for two invocations of synchronized methods on the same object to interleave."

What does this mean for a

static method
? Since a static method has no associated object, will the synchronized keyword lock on the class, instead of the object?

Answer

Since a static method has no associated object, will the synchronized keyword lock on the class, instead of the object?

Yes. :)

Comments