Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Thread.isActive() after an uncaught exception in the "main" thread?


  • From: s355171@xxxxxxxxxxxxxxxxx (Benjamin Johnston)
  • Subject: Thread.isActive() after an uncaught exception in the "main" thread?
  • Date: Sun, 30 Jan 2000 23:41:09 +1000

Hi,

I've noticed that if the main thread throws an uncaught exception that
causes execution to stop, then the thread remains alive (ie.
Thread.isAlive() returns true), but if a new thread is created and throws an
exception then Thread.isAlive() returns false. If the main thread exits
normally, by returning from the main method, Thread.isAlive() returns false.

This means that calling mainthread.join() from another thread (that has been
started from the main thread) never returns (that was how I originally
discovered it).

Is that the correct behaviour, or a bug?
If it is the correct behaviour, is there a way around it (so I can wait
until the main method has finished or thrown an uncaught exception)?
I'm using the JBuilder3 VM and JBuilderFoundation VM on Windows 98.

(BTW, the VM will still exit if the main thread throws an exception -- so
the main thread must be terminating (according to the JLS (version 1.0)
section 12.9)).

When I say, "main thread", I mean the thread that is returned by calling
Thread.currentThread() in the main method of the application (ie. the thread
that "runs" the "public static void main(String[])" method).

-Benjamin Johnston
s355171@xxxxxxxxxxxxxxxxx



---
To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx