wood burning stoves 2.0*
The moose likes Java in General and the fly likes Singleton instance lifecycle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Singleton instance lifecycle" Watch "Singleton instance lifecycle" New topic
Author

Singleton instance lifecycle

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Guys,

How is the lifecycle of a POJO Singleton instance managed in an app / web server. I have a Singleton class and this will be accessed by some components which are under the control of an app server. Now upon first request for this Singleton instance, the ClassLoader will load the class in memory, create an instance and is this instance retained in the memory untill the app server is brought down?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Until the class is unloaded, which usually indeed is when the app server (or JVM for standalone apps) is shut down.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

Even I asked this question once!


[List of FAQs] | [Android FAQ] | [Samuh Varta]
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Thanks for the information.
 
Don't get me started about those stupid light bulbs.
 
subject: Singleton instance lifecycle
 
Similar Threads
Weblogic cluster question
Singletons and memory leaks
Singleton and java garbage collection...and issue?
Singleton - Diff WAR files - same JVM - instances?
ServiceLocator/Singleton as an cache in clustered environment