Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4014091
Votes 0
Synopsis AWT threads don't quit when you expect them to.
Category java:classes_awt
Reported Against 1.1
Release Fixed
State 11-Closed, duplicate of 4030718, bug
Priority: 3-Medium
Related Bugs 4030718
Submit Date 11-NOV-1996
Description
Once an application creates an AWT component such as a Frame, then
even if all AWT components go away, the AWT threads still exist and
run.  This means that even if a program exits its main method, the
program will continue to run until some bit of code calls System.exit.

Below is a test case.  The following application doesn't exit unless
you uncomment the System.exit call.

import java.awt.*;
public class Test
{
    public static void main(String argv[])
    {
	Frame f = new Frame();
	f.show();
	f.hide();
	f = null;
	//System.exit(0);
    }
}
Work Around
N/A
Evaluation
We've found several applications that unfortunately rely on that behavior, and therefore can't correct this problem because of the need for backwards compatibility.
Comments
  
  Include a link with my name & email   

Submitted On 10-NOV-1997
dobri
There is a statement in 100% Pure Java documentation that you can't use
System.exit()
in order your program to be 100% pure. How to end it?


Submitted On 19-DEC-1997
jeffjohnson
This seems to be a confirmed bug in Bug numbers 4072987 and 4038690.  The
workaround is to call System.exit(0) but it's far from ideal.


Submitted On 12-JAN-1998
sz9
Can't the applications relying on this behaviour just
install another thread that just keeps them going even 
after the last AWT Component was disposed?
This to me appears to be a far more sensible solution than
the one currently preferred. For normal everyday usage
of AWT it is only natural to assume that the program
quit "whenever the last frame is closed".


Submitted On 25-AUG-1999
axell
Making old bugs ito new features? Isn't that what Microsoft keeps getting
accused of? This is just silly and dissapointing! 
This misfeature makes it REALLY difficult to determine when a complex
application using multiple windows should quit. 


Submitted On 25-JUL-2000
muthujkumaran
even this happend while run the RMI server class also.


Submitted On 11-FEB-2002
knollc
I would just like to say that it was a BAD call telling
people to use System.exit() to work around an obvious JVM
resource leak. And now that client side applications are
becomming more wide spread, and the need for shared jvms is
becomming more and more necessary, applications calling
System.exit() will now effectively destroy each other. 
Thanks for the forward-thinking solution.

-Chris


Submitted On 11-APR-2002
jcb005
I have to agree with knollc.
The JVMs are going to have to start supporting multiple 
applications and this makes that impossible.

I also agree with sz9.  The programs have an easy way out.
Just create a thread that doesn't terminate.

Please don't hold up future progress, because of such a 
glaring bug. 


Submitted On 12-APR-2002
echawkes
I believe this was fixed in 1.4.  See 4030718.  



PLEASE NOTE: JDK6 is formerly known as Project Mustang