It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes synchronized static methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "synchronized static methods" Watch "synchronized static methods" New topic

synchronized static methods

mayur dhawan
Ranch Hand

Joined: Sep 20, 2005
Posts: 30
If we declare a method as public synchronized static void doThings(){}

then will the executing thread automatically take the Class lock?
If yes then can you explain how?

thanks in advance
camilo lopes
Ranch Hand

Joined: Aug 08, 2007
Posts: 202
because one method static pertence the class then if you lock the o method static you isn't lock one instance and so the class.
always that you use static the atributte pertence the class. don't forget.

Brazil - Sun Certified Java Programmer - SCJP 5 About Java - Update every Week.
Guide SCJP - tips that you need know
I agree. Here's the link:
subject: synchronized static methods
It's not a secret anymore!