Article View: borland.public.jbuilder.java.language
Article #15501Re: Singleton pattern impossible in Java?
From: Thomas Moore
Date: Tue, 01 Jun 1999 00:00
Date: Tue, 01 Jun 1999 00:00
24 lines
1573 bytes
1573 bytes
Quoth Michael Boyle: > I have been unsuccessfully attempting to implement the singleton > pattern in my project. [snip] > Now, I realize that no object is storing a reference to my > TestApp instance, but surely any static member object of a > class should not be garbage collected. This is a known "feature" of Java. The solution is to have a SingletonRegistry running in a separate thread that maintains pointers to all singletons. Mark Grand outlines this sort of thing in Patterns in Java, Vol. 1, which I'd recommend. It's a Java-centric implementation of the GoF patterns along with some "extras", but it goes into some of the language specific issues you can encounter. -- Within C++ is a smaller, cleaner language struggling to get out. It's called Java. Thomas Moore tmoore@celwave.com Home Account Software.Engineer twmoore@home.net phone://732.462.1880:268 NJ Patterns Group Home Page employer://Celwave, RF http://members.home.net/twmoore/cjpg
Technical Details
Message-ID:
<375433B1.A731670E@celwave.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<375401EA.A6FBEDCA@adopt.qc.ca>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,6d4ef91dc0571b30 X-Google-Attributes: gidf74b3,public From: Thomas Moore <tmoore@celwave.com> Subject: Re: Singleton pattern impossible in Java? Date: 1999/06/01 Message-ID: <375433B1.A731670E@celwave.com> X-Deja-AN: 484571772 Content-Transfer-Encoding: 7bit References: <375401EA.A6FBEDCA@adopt.qc.ca> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language