• Post Reply Bookmark Topic Watch Topic
  • New Topic

difference between synchronized method and singleton object's method  RSS feed

 
Shubhendu Pramanik.
Greenhorn
Posts: 14
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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.
 
Amar Saikia
Ranch Hand
Posts: 43
2
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
Mike. J. Thompson
Bartender
Posts: 689
17
  • Likes 2
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank you very much for the answers. Its clear now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!