IntelliJ Java IDE
The moose likes Java in General and the fly likes Question on static synchronized method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Question on static synchronized method" Watch "Question on static synchronized method" New topic
Author

Question on static synchronized method

Brian Nguyen
Greenhorn

Joined: Mar 19, 2002
Posts: 22
Hello,
I am just curious about the following method declaration:
public static synchronized void methodA(){}
What is the meaning of "static" fiel here?
Does it mean that in an multithreaded environment, only one thread can call the above method of the class at a time?
Thanks for your answer in advance
Brian
Greg Charles
Bartender

Joined: Oct 01, 2001
Posts: 1855

Yes. Static in general means the method belongs to the class, rather than a particular instance of it. When you have a static synchronized method, it means threads calling it are synchronized on the class itself, not on an object. That is, one thread must execute that method (or any other synchronized method) completely before another thread is allowed to enter.
 
IntelliJ Java IDE
 
subject: Question on static synchronized method
 
Threads others viewed
static and non-static synchronized methods
synchronized(ObjectInstance){ //satements } AND Polymorphism
synchronized
An abstract method can NOT be declared static, synchronized,
regarding static method
IntelliJ Java IDE