I agree. The
static variable sm_instance would be GC'd
during the lifetime of the class only if it is explicitly null assigned. -- Radz Bill Littman wrote: --------------030405040701090006040708--Devashish-I may have misunderstood what you are saying, but the private static LogManager object is not being Garbage Collected. There is a reference to it throughout the life of your program, so it will never be GC'ed. Hope this helps. -Bill Littman -----Original Message----- From: devashish bajpai [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 18, 2004 7:06 AM To: Bill Littman Cc: [EMAIL PROTECTED] Subject: Re: RE: (no subject) i dont think that the problem is only of synchronisation . The problem is with Garbage Collection that collects the object as i use the SingeTon object without reference(see at the bottom how i m using it ) . thus Garbage Collection is taking place ...what can i do to keep the code of my project unchanged .. Devashish Bajpai On Thu, 18 Mar 2004 Bill Littman wrote :Or you could do this:static private LogManager sm_instance = new LogManager( System.out );static public LogManager getInstance(){return sm_instance;}-Bill-----Original Message-----From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf OfRadzSent: Wednesday, March 17, 2004 6:50 AMTo: devashish bajpaiCc: [EMAIL PROTECTED]Subject: Re: (no subject)Hi,You could make the getInstance method synchronizedwhich would ofcourse makes the execution of this block slower. Alsonot sure if it*actually* helps much but you could check out Doublechecked lockingidiom too.--Radzdevashish bajpai wrote:i have a proble i have made a class SingleTon .. iuse it in many places in my project .. but just haverelised that the calss is creating more intances...the code is as following ....public class LogManager{private java.io.PrintStream m_out;private LogManager( PrintStream out ){m_out = out;}public void log( String msg ){System.out.println( msg );}static private LogManager sm_instance;static public LogManager getInstance(){if ( sm_instance == null )sm_instance = new LogManager( System.out);return sm_instance;}}and using it like this ...LogManager.getInstance().log( "some message" );what sud i do ??__________________________________Do you Yahoo!?Yahoo! Mail - More reliable, more storage, less spamhttp://mail.yahoo.com_______________________________________________Swing mailing list[EMAIL PROTECTED]http://eos.dk/mailman/listinfo/swing_______________________________________________ Swing mailing list [EMAIL PROTECTED] http://eos.dk/mailman/listinfo/swing Do you Yahoo!? |
- (no subject) Macyn Hall
- (no subject) ؛«اب
- (no subject) kynn
- Re: combo box vs "Java Applet Window" Dmitry Beransky
- (no subject) devashish bajpai
- Re: (no subject) Radz
- RE: (no subject) Bill Littman
- Re: RE: (no subject) devashish bajpai
- RE: RE: (no subject) Bill Littman
- Re: RE: (no subject) Sachin Hejip
- Re: Re: RE: (no subject) Radz
- Re: Re: RE: (no subject) devashish bajpai
- Re: Re: RE: (no subject) Sachin Hejip
- RE: Re: RE: (no subject) Bill Littman