This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Singleton instance lifecycle" Watch "Singleton instance lifecycle" New topic

Singleton instance lifecycle

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 10033


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

Joined: Oct 27, 2005
Posts: 20279

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

How To Ask Questions How To Answer Questions
Monu Tripathi

Joined: Oct 12, 2008
Posts: 1369

Even I asked this question once!

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

Joined: Sep 26, 2006
Posts: 10033

Thanks for the information.
I agree. Here's the link:
subject: Singleton instance lifecycle
It's not a secret anymore!