Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multithreading Tomcat未使用ExecutorService通过线程化GWT应用程序正确关闭_Multithreading_Gwt_Tomcat_Memory Leaks - Fatal编程技术网

Multithreading Tomcat未使用ExecutorService通过线程化GWT应用程序正确关闭

Multithreading Tomcat未使用ExecutorService通过线程化GWT应用程序正确关闭,multithreading,gwt,tomcat,memory-leaks,Multithreading,Gwt,Tomcat,Memory Leaks,我在使用两个SingleThreadExecutor线程和一个FixedThreadPool的GoogleWebToolkit应用程序时遇到问题。我可以从catalina.out日志中看到线程没有正确关闭,这导致tomcat进程继续运行: INFO: Stopping service Catalina Oct 30, 2012 2:16:48 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE

我在使用两个SingleThreadExecutor线程和一个FixedThreadPool的GoogleWebToolkit应用程序时遇到问题。我可以从catalina.out日志中看到线程没有正确关闭,这导致tomcat进程继续运行:

INFO: Stopping service Catalina
Oct 30, 2012 2:16:48 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/btq] appears to have started a thread named [pool-4-thread-1] but has failed to stop it. This is very likely to create a memory leak.
Oct 30, 2012 2:16:48 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/btq] appears to have started a thread named [pool-5-thread-1] but has failed to stop it. This is very likely to create a memory leak.
Oct 30, 2012 2:16:48 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/btq] appears to have started a thread named [Thread-4] but has failed to stop it. This is very likely to create a memory leak.
我找到了一些关于使用ServletContextListener来处理这类事情的参考资料,但在我的情况下,让它工作起来有问题

在一次尝试中,我将ServletContextListener添加到我的GUIImpl类中,该类是GWT代码的服务器端实现:

public class GUIImpl extends RemoteServiceServlet implements GUI, ServletContextListener
我想这可能不是通常的做法,但我尝试这样做,因为实例化ExecutorService的类位于另一个包中,该包包含一些与其他项目共享的代码。我的实现只是在其他类上调用了一些关闭函数,但是我得到了一些异常

    @Override
public void contextDestroyed(ServletContextEvent event) {

    this.context = event.getServletContext();
    context.log( "FUNCTION: GUIImpl.contextDestroyed - called" );

    // Tell the Presenter to shut down
    presenter.shutdown();
}
Presenter类具有FileSystemMonitor类的实例,FileSystemMonitor类是实例化执行器的类。日志中的例外情况是:

Oct 30, 2012 2:16:48 PM org.apache.catalina.core.ApplicationContext log
INFO: FUNCTION: GUIImpl.contextDestroyed - called
Oct 30, 2012 2:16:48 PM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class com.mdaus.btq.gui.server.GUIImpl
java.lang.NullPointerException
  at com.mdaus.btq.gui.server.GUIImpl.contextDestroyed(GUIImpl.java:1236)
  at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4831)
  at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478)
  at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
  at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1575)
  at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1564)
  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
  at java.util.concurrent.FutureTask.run(FutureTask.java:166)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
  at java.lang.Thread.run(Thread.java:722)

Oct 30, 2012 2:16:48 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextDestroyed()
Oct 30, 2012 2:16:48 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextDestroyed()
很抱歉,如果问题有点长而且令人困惑,但是我现在有点困惑,因为我没有编写原始代码

有人知道如何关闭这些线程吗