当我的小程序在网络浏览器中停止时,我的行为很奇怪
Exception in thread "SwingWorker-pool-1-thread-3" java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThread)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at sun.applet.AppletSecurity.checkAccess(AppletSecurity.java:214)
at java.lang.Thread.checkAccess(Thread.java:1330)
at java.lang.Thread.interrupt(Thread.java:903)
at java.util.concurrent.ThreadPoolExecutor$Worker.interruptIfIdle(ThreadPoolExecutor.java:844)
at java.util.concurrent.ThreadPoolExecutor.interruptIdleWorkers(ThreadPoolExecutor.java:994)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:952)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:680)
谁能解释一下这个问题吗?
杰森
<小时/>在追踪另一个错误时,我将代码简化到最低限度,并在此过程中找到了引发此异常的原因:
new ImageLoaderWorker(this,background.setCoordinatesCenter(400, 240)).execute();
背景包含有用的信息,例如路径尺寸等。
ImageLoaderWorker 的定义如下:
public class ImageLoaderWorker extends SwingWorker<ImageIcon, Void> {
@Override
public ImageIcon doInBackground() {
System.err.println("do in background");
return loadImage();
}
@Override
public void done() {
System.err.println("done");
try {
if(!sskkWhitePages.containsKey(iich.getName())){
sskkWhitePages.put(iich.getName(), get());
}
iich.transfertImage();
if(callback != null){
callback.imageLoaded(iich.getName());
}
} catch (InterruptedException ignore) {}
catch (java.util.concurrent.ExecutionException e) {
String why = null;
Throwable cause = e.getCause();
if (cause != null) {
why = cause.getMessage();
} else {
why = e.getMessage();
}
System.err.println("Error retrieving file: " + why);
}
}
/**
* Load the image for the specified frame of animation. Since
* this runs as an applet, we use getResourceAsStream for
* efficiency and so it'll work in older versions of Java Plug-in.
*/
protected ImageIcon loadImage() {
//Not really relevant to the problem I think so I skipped it to avoir overloading the question
}
最佳答案
我认为这可能是 JDK 错误 - 请参阅此 NetBeans bug report .
NetBeans 错误报告引用了 JDK 错误 ID,并表示该错误已在 Java 6 中修复。但所引用的 JDK 错误已无法再访问。
如果您的浏览器有 Java 5 插件,这是一个合理的解释,而合理的修复方法是将插件升级到 Java 6。
关于java - 小程序:关闭时触发异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6286098/