aspose file tools*
The moose likes Threads and Synchronization and the fly likes Static Synchronized methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Static Synchronized methods" Watch "Static Synchronized methods" New topic
Author

Static Synchronized methods

lakshmi v.samy
Ranch Hand

Joined: Feb 02, 2006
Posts: 30
Hi everybody
I have one situation like this,two different threads are there.they are going to execute two different static sychronized methods.my questions if one thread is executing one static synchronized method whether other method will be blocked otherwise both will be executed simultaneously.
please guide me.
Thanks in advance
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18719
    
  40

Originally posted by lakshmi v.samy:
Hi everybody
I have one situation like this,two different threads are there.they are going to execute two different static sychronized methods.my questions if one thread is executing one static synchronized method whether other method will be blocked otherwise both will be executed simultaneously.
please guide me.
Thanks in advance


If one thread is executing a static synchronized method, all other threads trying to execute any static synchonized method, in the same class, will block.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
It's useful to realize that the syntax for synchronized methods and static synchronized methods is just syntactic sugar, and that you can use synchronized blocks in their place:

It's not clear whether the original poster was thinking of static methods in the same class or across classes, but if you use the more explicit synchronized block syntax, you can have it as you like.


There is no emoticon for what I am feeling!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Static Synchronized methods