java - 转储文件中的特殊 java 线程

标签 java jvm dump jstack

当我的java应用程序变得无响应时,我使用jstack -F(如果我在没有-F标志的情况下运行jstack,它不会给我任何东西)命令来转储线程信息,并且转储文件中有一个特殊的线程。

Thread 110175: (state = IN_VM)
 - sun.misc.Unsafe.freeMemory(long) @bci=0 (Compiled frame; information may be imprecise)
 - java.nio.DirectByteBuffer$Deallocator.run() @bci=17, line=94 (Compiled frame)
 - sun.misc.Cleaner.clean() @bci=12, line=143 (Compiled frame)
 - io.netty.util.internal.Cleaner0.freeDirectBuffer(java.nio.ByteBuffer) @bci=34, line=66 (Compiled frame)
 - io.netty.util.internal.PlatformDependent0.freeDirectBuffer(java.nio.ByteBuffer) @bci=1, line=147 (Compiled frame)
 - io.netty.util.internal.PlatformDependent.freeDirectBuffer(java.nio.ByteBuffer) @bci=13, line=281 (Compiled frame)
 - io.netty.buffer.UnpooledUnsafeDirectByteBuf.freeDirect(java.nio.ByteBuffer) @bci=1, line=115 (Compiled frame)
 - io.netty.buffer.UnpooledUnsafeDirectByteBuf.deallocate() @bci=24, line=508 (Compiled frame)
 - io.netty.buffer.AbstractReferenceCountedByteBuf.release() @bci=39, line=106 (Compiled frame)
 - io.netty.util.ReferenceCountUtil.release(java.lang.Object) @bci=11, line=59 (Compiled frame)
 - io.netty.util.ReferenceCountUtil.safeRelease(java.lang.Object) @bci=1, line=84 (Compiled frame)
 - io.netty.channel.ChannelOutboundBuffer.remove() @bci=40, line=258 (Compiled frame)
 - io.netty.channel.ChannelOutboundBuffer.removeBytes(long) @bci=83, line=334 (Compiled frame)
 - io.netty.channel.socket.nio.NioSocketChannel.doWrite(io.netty.channel.ChannelOutboundBuffer) @bci=238, line=301 (Compiled frame)
 - io.netty.channel.AbstractChannel$AbstractUnsafe.flush0() @bci=89, line=716 (Compiled frame)
 - io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.flush0() @bci=9, line=303 (Compiled frame)
 - io.netty.channel.AbstractChannel$AbstractUnsafe.flush() @bci=15, line=685 (Compiled frame)
 - io.netty.channel.DefaultChannelPipeline$HeadContext.flush(io.netty.channel.ChannelHandlerContext) @bci=4, line=1118 (Compiled frame)
 - io.netty.channel.AbstractChannelHandlerContext.invokeFlush() @bci=8, line=663 (Compiled frame)
 - io.netty.channel.AbstractChannelHandlerContext.access$1500(io.netty.channel.AbstractChannelHandlerContext) @bci=1, line=32 (Compiled frame)
 - io.netty.channel.AbstractChannelHandlerContext$16.run() @bci=4, line=651 (Compiled frame)
 - io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(long) @bci=26, line=380 (Compiled frame)
 - io.netty.channel.nio.NioEventLoop.run() @bci=106, line=357 (Compiled frame)
 - io.netty.util.concurrent.SingleThreadEventExecutor$2.run() @bci=13, line=116 (Interpreted frame)
 - java.lang.Thread.run() @bci=11, line=745 (Interpreted frame)

在我使用jstack -F之后,应用程序开始响应并继续下去,就像什么也没发生一样,直到它最终再次停止响应。

当应用正常时,我使用jstack -F搜索最后一个线程,它总是IN_NATIVE

这是我的问题。

  1. 此线程会使我的应用程序无响应吗?
  2. 这个话题是什么?

最佳答案

正如您在线程的堆栈跟踪中看到的,大多数调用都在 io.netty 包中。

底部的两个类,SingleThreadEventExecutor 和 NioEventLoop,在它们的 Javadoc 中表明它们是通用事件调度程序线程。因此,其中运行的代码可以是任何代码。据推测,它经常运行您的代码。

所以回答你的问题

  1. 是的,但前提是它运行的代码需要太长时间/使用太多 CPU 来处理您的硬件配置的事件。这可能是来自 netty 框架的其他代码,也可能是您的代码。
  2. 这是一个通用事件调度程序线程。这不是一个特殊的线程。

关于java - 转储文件中的特殊 java 线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34407515/

相关文章:

java - 参数索引超出范围(2 > 参数个数,即 1)

java - Jython 是我的代码库中的负担吗?

windows - 如何在 Windows 平台上禁用 JVM 以运行后台 matlab 脚本

java - Scala 中隐藏的性能成本?

c# - 将资源从 Unity 游戏转储到文件

java : Extend Applet process timeout

java - 使用 jframe 时找不到符号错误

windows - 在 windbg 中调试 "release-mode"二进制文件/转储

Java 事件调度线程被阻塞

Android 不授予转储权限