How to use Enum as Singleton in Java with Example

Tutorials Shared by the Internet Community

Advertisements

  Top Tutorials     New Tutorials     Submit     Login     Register  

Tutorial Detail

How to use Enum as Singleton in Java with Example

From Java 5 onwards there is a new way to implement Singleton design pattern, by using Enum. Enum has some distinct benefits in terms of thread-safety
http://javarevisited.blogspot.com/2012/07/why-enum-singleton-are-better-in-java.html
  • Total Hits: 19566

  • Average Rating :
    URL RatingURL RatingURL RatingURL RatingURL Rating

  •  

  • Total Votes: 150 votes

  • Category: JAVA/Getting Started

  • Submitted on: 2012-11-01 15:37:10

  • Submitted By: Javin Paul

  • Set as Favorite

Description:

From Java 5 onwards there is a new way to implement Singleton design pattern, by using Enum. Enum has some distinct benefits in terms of thread-safety during instance creation, serialization guarantee by JVM and amazingly reduce amount of code which makes it perfect choice of using as Singleton class.    More detail...

Rating Detail

 Stars  Percentage  Total Vote
 One star  Vote LeftVote MiddleVote Right 40%  60
 Two starsTwo star  Vote LeftVote MiddleVote Right 9.33%  14
 Three starsThree starsThree stars  Vote LeftVote MiddleVote Right 11.33%  17
 Four starsFour starsFour starsFour stars  Vote LeftVote MiddleVote Right 10%  15
 Five starsFive starsFive starsFive starsFive stars  Vote LeftVote MiddleVote Right 29.33%  44

Caste Your Vote

 Rating  Selection  Guidelines
 Poor:     Very disappointing, useless.
 Fair:     Below average, disappointing but not useless.
 Good:     About average in its class.
 Very Good:     Above average for its category.
 Excellent:     One of the best Tutorials in its category.






Advertisements