【发布时间】:2014-01-20 21:06:41
【问题描述】:
我在我的树莓派上运行一个 Tomcat 服务器。当有人浏览我的服务器时,servlet 会启动一个 JFrame,在我的电视(连接到 Pi)上显示一些信息。
这就是它的制作方式,在 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方法中销毁框架。
标签: java jakarta-ee tomcat servlets jframe