• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Class level syncronization v/s Method level Syncronization

 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic