Tom Tromey wrote:

>>>>>>"Patrick" == Patrick Doyle <[EMAIL PROTECTED]> writes:
>>>>>>
>
>Patrick> What's the easiest way to implement this?  Does ThreadGroup
>Patrick> provide enough functionality to do it?  Or do I have to
>Patrick> maintain a list of active threads myself?  Does Classpath
>Patrick> have any additional functionality to support this?
>
>In libgcj we have a master thread which simply waits on a condition
>variable.  When a new thread is started, an active thread count is
>incremented.  When a thread dies, the count is decremented and the
>master thread is notified.  If it finds that the count is zero, the VM
>shuts down. 
>
An alternate technique would be to simply have each non-daemon check the 
counter as it exits. If its 0 (after decrementing for itself) then call 
Runtime.exit().

Recently in libgcj we made the "master" thread actually the "main" 
thread as well - first it runs main() then it sits waiting for other 
non-daemons to exit. See _Jv_RunMain() in libjava/prims.cc.

> In our implementation ThreadGroup doesn't enter the
>picture.  
>
There is a special case where we want to exit the runtime with an error 
status if a thread threw an uncaught exception. We look at 
threadgroup.had_uncaught_exception to determine that.

regards

Bryce.



_______________________________________________
Classpath mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/classpath

Reply via email to