• 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

difference between synchronized method and singleton object's method

 
Greenhorn
Posts: 14
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think my concept is not clear about synchronization and singleton object. What is the difference between synchronized method and singleton object's method ?
Thanks in advance.
 
Ranch Hand
Posts: 43
2
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a multi-threading environment, only one thread can access a synchronized method at a time. However, a singleton object's method can be accessed by any number of threads simultaneously.
 
Bartender
Posts: 689
17
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Subho Pramanik wrote:I think my concept is not clear about synchronization and singleton object. What is the difference between synchronized method and singleton object's method ?
Thanks in advance.



There is no relationship between synchronization and singletons. A Singleton is a class that ensures only one instance of the class can exist, and is a design pattern (or a design anti-pattern depending on your viewpoint).

A singletons methods can be synchronized or not synchronized, just like any other method.
 
Shubhendu Pramanik.
Greenhorn
Posts: 14
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for the answers. Its clear now.
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic