JDK-4079015 : AWT internal thread is non deamon
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.3
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_95
  • CPU: x86
  • Submitted: 1997-09-15
  • Updated: 1998-02-13
  • Resolved: 1998-02-13
Related Reports
Duplicate :  
Description

Name: paC48320			Date: 09/15/97


To reproduce the problem:
  Run the following program. I would expect it to stop on exit from Main.main, but it doesn't.


import java.awt.*;

public final class Main 
{
  public static void main(String[] arguments) 
    {
      Frame frame = new Frame(); /* Note that I do not show this frame */
      FileDialog dlg = new FileDialog(frame, "Load File", FileDialog.LOAD);
      dlg.show();
      System.out.println("Directory name : " + dlg.getDirectory() +
        System.getProperty("line.separator") +
        "File name: " + dlg.getFile());
      dlg.dispose(); /* Just to make sure... */
      frame.dispose();
      dlg=null; /* Let's be really sure... */
      frame=null;
      System.gc(); /* This should be enough... */
    } /* But NO!!! The program does not exit!!!! */
}

If you investigate further, you will notice that the AWT creates an internal thread but it doesn't flag it as a deamon thread. This is why the application remains suspended.

This thread should be made a deamon, because  it is really specific to the implementation of the AWT. 
The JLS says that a program exits as soon as all non deamon threads are dead. This problem prevents this from happening (from a programmer's perspective).

company - ACAPS research team , email - ###@###.###
======================================================================

Comments
WORK AROUND Name: paC48320 Date: 09/15/97 Call system.exit. But the 100 percent pure Java cookbook recommends not doing that. This is just a workaround. It doesn't solve the problem. ======================================================================
11-06-2004