sun.misc.Unsafe.park(Native Method)

Posted ai-hen-jiao-zhi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sun.misc.Unsafe.park(Native Method)相关的知识,希望对你有一定的参考价值。

关闭tomcat时或者重启tomcat时 log4j2 报错: sun.misc.Unsafe.park(Native Method)

异常信息:

30-Aug-2018 15:59:34.900 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoader.clearReferencesThreads The web application [] appears to have started a thread named [Thread-14] but has failed to stop it. This is very likely to create a memory leak.
30-Aug-2018 15:59:34.901 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoader.clearReferencesThreads Stack trace of thread "Thread-14":
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)

 

 

新项目使用log4j2+springmvc的方式,但是报这个错,查了很多资料,原因是log4j2-2.6开始引入shutdown(),在2.6中,如果web app卸载时没有进行shutdown(),tomcat会发布内存泄漏风险的告警。

在web.xml里加入下边代码块,要放在spring相关配置前边

  <listener>
    <listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>
  </listener>
  <context-param>
    <param-name>isLog4jAutoInitializationDisabled</param-name>
    <param-value>true</param-value>
  </context-param>

以上是关于sun.misc.Unsafe.park(Native Method)的主要内容,如果未能解决你的问题,请参考以下文章

Thread.State: WAITING (parking) vs BLOCKED at sun.misc.Unsafe.park() 有啥区别

线程处于 WAITING 状态:java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method)

Java ExecutorService - 处于等待状态的线程

spring-cloud-alibaba-sentinel和feign配合使用,启动报Caused by: java.lang.AbstractMethodError: com.alibaba.clo

SyntaxError - node_modules/react-native/Libraries/polyfills/error-guard.js:缺少分号。 (14:4) 在 react nati

高阶组件