Java版 - Concurrent Exception in Swing |
|
|
|
|
|
b***i 发帖数: 3043 | 1 遇到一个Exception,忘了截屏了,大概是Nimbus Look and Feel试图什么东西,发生
了concurrent的exception。代码是
public static Debug= new JCheckBox("Debug");
就是说,没有使用invokeLater,可能Swing多线程的情况下,修改了一个容器类的变量
,导致冲突。我估计得改成invokeLater,invokeAndWait吧? | g*****g 发帖数: 34805 | 2 ConcurrentModificationException?
You get it if you try to modify a collection while iterating on it, single
thread.
【在 b***i 的大作中提到】 : 遇到一个Exception,忘了截屏了,大概是Nimbus Look and Feel试图什么东西,发生 : 了concurrent的exception。代码是 : public static Debug= new JCheckBox("Debug"); : 就是说,没有使用invokeLater,可能Swing多线程的情况下,修改了一个容器类的变量 : ,导致冲突。我估计得改成invokeLater,invokeAndWait吧?
| b***i 发帖数: 3043 | 3 我在main里面调用一个自己写的类OldSplashScreen的函数,起了一个线程,执行
splash()(其中145行splashWindow = new SplashWindow(this,fImage);)
178在一个private class SplashWindow extends JFrame的类中,是构造函数
private class SplashWindow extends JFrame {
BufferedImage base=null;
public Graphics2D gS=null;
private static final long serialVersionUID = 1L;
BufferedImage bf=null;
BufferedImage canvas=null;
178: SplashWindow(Frame aParent, Image aImage) {
构造函数怎么会出错?我估计是非Swing EDT里面调用Swing类Frame子类的构造函数了。
另外,我main里面设定了Nimbus的lookandfeel,另有一个JFrame同时在构造中,这个
窗口的构造在invokeandwait里面。会不会就是这个SplashWindow没有放在EDT中?
出错信息如下
Exception in thread "Thread-4" java.util.ConcurrentModificationException
at java.util.Hashtable$Enumerator.next(Unknown Source)
at com.sun.java.swing.plaf.nimbus.NimbusStyle.compileDefaults(Unknown S
at com.sun.java.swing.plaf.nimbus.NimbusStyle.validate(Unknown Source)
at com.sun.java.swing.plaf.nimbus.NimbusStyle.getValues(Unknown Source)
at com.sun.java.swing.plaf.nimbus.NimbusStyle.getInsets(Unknown Source)
at javax.swing.plaf.synth.SynthStyle.installDefaults(Unknown Source)
at javax.swing.plaf.synth.SynthLookAndFeel.updateStyle(Unknown Source)
at javax.swing.plaf.synth.SynthPanelUI.updateStyle(Unknown Source)
at javax.swing.plaf.synth.SynthPanelUI.installDefaults(Unknown Source)
at javax.swing.plaf.basic.BasicPanelUI.installUI(Unknown Source)
at javax.swing.plaf.synth.SynthPanelUI.installUI(Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.JPanel.setUI(Unknown Source)
at javax.swing.JPanel.updateUI(Unknown Source)
at javax.swing.JPanel.(Unknown Source)
at javax.swing.JPanel.(Unknown Source)
at javax.swing.JPanel.(Unknown Source)
at javax.swing.JRootPane.createGlassPane(Unknown Source)
at javax.swing.JRootPane.(Unknown Source)
at javax.swing.JFrame.createRootPane(Unknown Source)
at javax.swing.JFrame.frameInit(Unknown Source)
at javax.swing.JFrame.(Unknown Source)
at mylib.OldSplashScreen$SplashWindow.(OldSplashScreen.java:178)
at mylib.OldSplashScreen.splash(OldSplashScreen.java:145)
at mylib.OldSplashScreen.run(OldSplashScreen.java:33)
at java.lang.Thread.run(Unknown Source)
【在 g*****g 的大作中提到】 : ConcurrentModificationException? : You get it if you try to modify a collection while iterating on it, single : thread.
|
|
|
|
|
|