Can a static method be declared as synchronized?


Ans:
You can synchronize static methods to prevent more than one thread from executing either one or both at a time. This does not, however, have any effect on synchronized instance methods. Synchronized static methods synchronize on the relevant Class object; synchronized instance methods synchronize on the instance. You can also synchronize on a static Object if you like (in either static or instance methods); this provides means for finer grained synchronization and / or synchronization across instances.

People who read this post also read :



0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More