• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Static Synchronized methods  RSS feed

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
author
Sheriff
Posts: 23586
138
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!