----- Original Message -----
Sent: Friday, March 19, 2004 3:05
PM
Subject: Re: Re: RE: (no subject)
yes u r correct .. i m useing the static function to access the
function of singleton calss .. but it is been garbage collected as the
referecne to the calss object falles weak ...
now i have 2 ques ..
(1)
is there a way by which solve this problem .without changing the way to access
the class ? ...that is changing the code of singleton class but not
chaning the code of any other calss ..
(2) if yes then how ?
devashish
On Thu, 18 Mar 2004 Sachin Hejip wrote
:
>Correct me if I am wrong here but it will get garbage collected if
the class
>loader that loaded this class is going to get garbage
collected and none of
>the classes it refers to are
reachable.
>Btw, I think that is what your problem is. That your class
is being loaded
>by some other class loader. (is it an application
server that you are
>running your code
in?)
>
>Regards
>Sachin
>----- Original Message
-----
> From: "Bill Littman" <[EMAIL PROTECTED]>
>To:
"devashish bajpai" <[EMAIL PROTECTED]>
>Cc:
<[EMAIL PROTECTED]>
>Sent: Thursday, March 18, 2004 7:03
PM
>Subject: RE: RE: (no
subject)
>
>
>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 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
> >
>
>
>
>
>
>_______________________________________________
>Swing
mailing
list
>[EMAIL PROTECTED]
>http://eos.dk/mailman/listinfo/swing
>
>
>_______________________________________________
>Swing
mailing
list
>[EMAIL PROTECTED]
>http://eos.dk/mailman/listinfo/swing