Kill a thread automatically

From: Adi Schwarz (adolf.schwarz.news.01-04_at_gmx.at)
Date: 01/30/04


Date: Fri, 30 Jan 2004 15:39:32 +0100

Hi,

If I have a class that runs a thread and no reference points to it, the
gc won't finalize the class because the thread is still running -> so
stopping the thread in the finalize() method won't work. Afaik this is
also true for daemon threads.

Is it possible to stop a thread automatically when there are no
references left? In my case it does not matter if the thread is
gracefully interrupted or just killed and whiped out.

greets,
-adi



Relevant Pages

  • Re: Finalization, Weak References and ResidueObject
    ... I was just under the impression that if an object's finalize method was ... ResidueObject or a 0. ... you try to display an object that has been garbage-collected an instant ... reference to whatever object inside the WeakArray, ...
    (comp.lang.smalltalk)
  • Re: Write-to-disk cache via WeakReferences?
    ... That means the code that does either the pollor removewill always get a reference with null for the referrent value of get. ... Create a class that extends WeakReference with the weak reference to the proxy and a strong reference to the resource. ... Sometime after the Proxy is collected, the WeakReference pops up on the reference queue, and you can get the strong reference to the resource from that. ... When finalize is called, resurrect the resource by putting it on a queue. ...
    (comp.lang.java.programmer)
  • Re: Problems with controlled types, gnatmem thinks handle is leaking memory (long)
    ... No need to check for the reference count to be 0, ... I suppose I could raise an exception if the reference count isn't zero on ... finalize subprograms have been implemented correctly. ... (The compiler will finalize them anyway so you'll get an ...
    (comp.lang.ada)
  • Re: Kill a thread automatically
    ... > If I have a class that runs a thread and no reference points to it, ... Relying on a call to finalize() is bad practice, ... a Thread if it is in a state where an interrupt might occur (generally sleep ... IBM Australia - Tivoli Security Software ...
    (comp.lang.java.programmer)
  • Re: Some OO design principles WAS Re: Differences in data description in programming languages
    ... >>01 Object2 object reference value null. ... copyfile which handles the various 'finalize' methods which at class ... Reuse 'Purist' it would appear to make sense to have a separate class ... MyFinalizer which includes the copy routines. ...
    (comp.lang.cobol)