Yes, they achieve the same thing -- locking Foo.class
. Here's the relevant excerpt from the Java Language Specification, Section 8.4.3.6:
For a class (static) method, the monitor associated with the Class object for the method's class is used.
Using synchronized
on the static func_1()
or func_2()
methods in your Foo
class locks the Foo.class
implicitly, while synchronized(Foo.class)
locks it explicitly.