我在我的树莓派上运行Tomcat服务器。当有人浏览我的服务器时,servlet启动一个JFrame,显示我的电视(连接到Pi)的一些信息。Tomcat servlets和JFrame
这是制造的原理,在servlet:
public static JFrame gui;
@Override
public void init() throws ServletException { // super.init() not needed
if (gui==null) gui = launchUi();
else if(!gui.isVisible()) gui.setVisible(true);
}
的问题是,当我停止服务器,JFrame中未关闭。这是我在Tomcat日志中找到的。
janv. 20, 2014 9:53:18 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/myapp] appears to have started a thread named [AWT-Shutdown] but has failed to stop it. This is very likely to create a memory leak.
janv. 20, 2014 9:53:18 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/myapp] appears to have started a thread named [AWT-EventQueue-0] but has failed to stop it. This is very likely to create a memory leak.
我该如何强制JFrame被关闭?或者我做这一切都错了? (什么是正确的方法呢?) 感谢
如果能在第一时间显示的'JFrame',你应该能够摧毁框架中'finalize'方法。 –