File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "synchronized static methods" Watch "synchronized static methods" New topic
Author

synchronized static methods

mayur dhawan
Greenhorn

Joined: Sep 20, 2005
Posts: 29
Hi,
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
mayur
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
http://www.camilolopes.com/ About Java - Update every Week.
Guide SCJP - tips that you need know http://blog.camilolopes.com.br/livrosrevistaspalestras/
 
Don't get me started about those stupid light bulbs.
 
subject: synchronized static methods
 
Similar Threads
synchronized method
synchronized
static synchronized block
locking style
class level lock and object level lock