• 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Class level syncronization v/s Method level Syncronization  RSS feed

 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I have never found out the difference between class level syncronization and method level organization.

Can anyone elaborate on the same with some example?

I have been asked this question many a times in the interview but never got answer for myself.

Thanks in advance,
saurabh
 
author and iconoclast
Posts: 24203
43
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's nothing called "method level synchonization" that contrasts with anything that could be called "class level sychronizations". One thing you might possibly be referring to is the difference between synchronization of class (static) methods and instance (non-static) methods. Instance methods are synchronized at the instance level -- i.e., threads compete for individual objects, but the same method can be called simultaneously on two separate objects. Static methods are synchronized on the Class object for the class, and all Threads must compete for that to call any static synchronized methods in a class.

I'm going to move this to our Threads and Synchronization forum; it surely isn't Advanced Java.
 
Are we home yet? Wait, did we forget the tiny ad?
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!