|
Typical Swing/AWT Event Dispatch Thread long-term occupation problem.
The method of handling events Before returning, all subsequent events of AWT's EventQueue, including the PAINT event, are blocked, so your interface cannot be refreshed, although you have updated the tree model.
Pay attention to Swing/AWT including SWT programming, and pay attention to two issues when dealing with long-term and heavy workload tasks:
* Time-consuming tasks should not be run on the Event Dispatch Thread. Otherwise the application becomes unresponsive.
Don't run tasks that consume events on the Event Dispatch Thread. Otherwise, the interface will be dead.
* Swing components should be accessed on the Event Dispatch Thread only.
Swing components can only be accessed in the Event Dispatch Thread.
A new class called SwingWorker was introduced in JDK 5 and JDK 6 to specifically solve this problem. For details, please refer to java API help:
http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/builds/latest/html/zh_CN/api/javax/swing/SwingWorker.html |
|