Java Swing Tutorials - Herong's Tutorial Examples - v4.30, by Dr. Herong Yang
JFrame Thread Behavior with JDK 8 to 12
This section provides a tutorial example on JFrame Thread behavior with JDK 1.8 to JDK 12.
I also tested the same program in JDK 8 to JDK 15. The result is different:
Test 1 - Run FrameThreads.java with JDK 15 in a command window and wait:
herong> java -version java version "15" 2020-09-15 Java(TM) SE Runtime Environment (build 15+36-1562) Java HotSpot(TM) 64-Bit Server VM (build 15+36-1562, mixed mode, sharing) C:\herong> java FrameThreads.java Active thread = main Active thread = AWT-EventQueue-0 Interrupting thread = AWT-EventQueue-0
Noticed that the "AWT-Shutdown" and "AWT-Windows" threads are not there anymore. They are probably moved to the "system" thread group now from the "main" thread group. The interruption did sent to the AWT-EventQueue-0 threat. But the 3 Swing frames were displayed on the screen forever.
Test 2 - Run FrameThreads.java in a command window, hide 3 frames behind another window and wait. I got the same results as test 1.
This tells me that AWT packages in JDK 1.8 to JDK 12 are still having some issues if its threads are interrupted. But it behaves consistently now.
Table of Contents