TopBlend: Here is the first difference. There are 1 differences. is old. is new.

AWT Threading Issues

Listeners and threads

Unless otherwise noted all AWT listeners are notified on the eventdispatch thread. It is safe to remove/add listeners from any threadduring dispatching, but the changes only effect subsequent notification.
For example, if a key listeners is added from another key listener, thenewly added listener is only notified on subsequent key events.

Auto-shutdown

According to The Java TM Virtual Machine Specification,Second edition (see ?2.17.9 and ?2.19 ),the Java virtual machine (JVM) initially starts up with a single non-daemonthread, which typically calls the main method of some class.The virtual machine terminates all its activity and exits whenone of two things happens:

This implies that if an application doesn't start any threads itself,the JVM will exit as soon as main terminates.This is not the case, however, for a simple applicationthat creates and displays a java.awt.Frame:


        public static void main(String[] args) {
            Frame frame = new Frame();
            frame.setVisible(true);
         }
The reason is that AWT encapsulates asynchronous event dispatchmachinery to process events AWT or Swing components can fire. Theexact behavior of this machinery is implementation-dependent. Inparticular, it can start non-daemon helper threads for its internalpurposes. In fact, these are the threads that prevent the exampleabove from exiting. The only restrictions imposed on the behavior ofthis machinery are as follows: The implications of the third restriction are as follows: It depends on the implementation if and when the non-daemon helperthreads are terminated once all components are made undisplayable. The implementation-specific details are given below.

Implementation-dependent behavior.

Prior to 1.4, the helper threads were never terminated.

Starting with 1.4, the behavior has changed as a result of the fix for 4030718 . With the current implementation, AWT terminates all itshelper threads allowing the application to exit cleanly when thefollowing three conditions are true:

Therefore, a stand-alone AWT application that wishes to exitcleanly without calling System.exit must: Note, that while an application following these recommendations willexit cleanly under normal conditions, it is not guaranteed that itwill exit cleanly in all cases. Two examples: On the other hand, if you require the JVM to continue running even afterthe application has made all components undisplayable you should start anon-daemon thread that blocks forever.

        <...>
        Runnable r = new Runnable() {
            public void run() {
                Object o = new Object();
                try {
                    synchronized (o) {
                        o.wait();
                    }
                } catch (InterruptedException ie) {
                }
            }
        };
        Thread t = new Thread(r);
        t.setDaemon(false);
        t.start();
        <...>
The Java Virtual Machine Specification guaranteesthat the JVM doesn't exit until this thread terminates.