开发环境
jdk8、tomcat8、IDEA
使用了ThreadPoolExecutor线程池,创建了几条线程,在我手动结束tomcat的时候,出现一下异常
04-Mar-2019 16:43:15.036 警告 [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.clearReferencesThreads The web application [test] appears to have started a thread named [Thread-48] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
报错的代码行是Thread.sleep(1000),我将线程睡了一会,为了是让其他线程可以拿到cpu的资源
目前采用的是在tomcat加监听器,在contextDestroyed方法里面加入了System.exit(0)直接结束掉jvm,不知道大佬们有没有遇到这样的问题,希望在评论区留下自己的解决办法。