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 Of Radz
> > Sent: Wednesday, March 17, 2004 6:50 AM
> > To: devashish bajpai
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: (no subject)
> >
> >
> > Hi,
> >
> >     You could make the getInstance method synchronized
> > which would of
> > course makes the execution of this block slower. Also
> > not sure if it
> > *actually* helps much but you could check out Double
> > checked locking
> > idiom too.
> >
> > --
> > Radz
> >
> > devashish bajpai wrote:
> >
> > >i have a proble i have made a class SingleTon .. i
> > use it in many places in my project .. but just have
> > relised 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 spam
> > http://mail.yahoo.com
> > _______________________________________________
> > Swing mailing list
> > [EMAIL PROTECTED]
> > http://eos.dk/mailman/listinfo/swing
> >

Reply via email to