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 Method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Synchronized Static Method" Watch "Synchronized Static Method" New topic
Author

Synchronized Static Method

Sun LiWei
Ranch Hand

Joined: Aug 10, 2002
Posts: 49
I am confused by synchronized on static method,just like this:

My question is:
Does the object pool synchronize???
In my mind,synchronized on method

is the same as

But in static method,the keyword "this" is not allowed.So,what exactly "synchronized static method()" mean???
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
When you synchronize on a static method you are placing a lock on the class for the duration of the static method.
-Barry


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Santosh Terkhedkar
Greenhorn

Joined: Mar 18, 2001
Posts: 2
Hi
Visit this link
http://www.javaworld.com/javaworld/jw-04-1999/jw-04-toolbox.html
read critical section in java Threads.
I think this will certainly help you solve your problem.
Cheers,
Santosh Terkhedkar.
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
synchronizing a static method locks on the java.lang.Class object representing the class, for instance in:

is the same as


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
When a class or interface is loaded a java.lang.Class instance is created to represent it. You can access references to them via the Class literals


SCJP2. Please Indent your code using UBB Code
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Synchronized Static Method