gpt4 book ai didi

java - jstack 文件中的 IN_NATIVE 是什么意思?

转载 作者:行者123 更新时间:2023-12-01 23:35:57 26 4
gpt4 key购买 nike

    Thread 10296: (state = IN_NATIVE)
- sun.nio.ch.Net.connect0(boolean, java.io.FileDescriptor, java.net.InetAddress, int) @bci=0 (Interpreted frame)
- sun.nio.ch.Net.connect(java.net.ProtocolFamily, java.io.FileDescriptor, java.net.InetAddress, int) @bci=25, line=465 (Interpreted frame)
- sun.nio.ch.Net.connect(java.io.FileDescriptor, java.net.InetAddress, int) @bci=6, line=457 (Interpreted frame)
- sun.nio.ch.SocketChannelImpl.connect(java.net.SocketAddress) @bci=225, line=670 (Interpreted frame)
- kafka.network.BlockingChannel.connect() @bci=135 (Interpreted frame)
- kafka.producer.SyncProducer.connect() @bci=21 (Interpreted frame)
- kafka.producer.SyncProducer.getOrMakeConnection() @bci=11 (Interpreted frame)
- kafka.producer.SyncProducer.kafka$producer$SyncProducer$$doSend(kafka.api.RequestOrResponse, boolean) @bci=13 (Interpreted frame)
- kafka.producer.SyncProducer.send(kafka.api.TopicMetadataRequest) @bci=6 (Interpreted frame)
- kafka.client.ClientUtils$.fetchTopicMetadata(scala.collection.Set, scala.collection.Seq, kafka.producer.ProducerConfig, int, kafka.auth.KafkaUser) @bci=189 (Interpreted frame)
- kafka.producer.BrokerPartitionInfo.updateInfo(scala.collection.immutable.Set, int) @bci=24 (Interpreted frame)
- kafka.producer.async.DefaultEventHandler$$anonfun$handle$2.apply$mcV$sp() @bci=54 (Interpreted frame)
- kafka.utils.Utils$.swallow(scala.Function2, scala.Function0) @bci=1 (Interpreted frame)
- kafka.utils.Logging$class.swallowError(kafka.utils.Logging, scala.Function0) @bci=12 (Interpreted frame)
- kafka.utils.Utils$.swallowError(scala.Function0) @bci=2 (Interpreted frame)
- kafka.producer.async.DefaultEventHandler.handle(scala.collection.Seq) @bci=269 (Interpreted frame)
- kafka.producer.Producer.send(scala.collection.Seq) @bci=45 (Interpreted frame)
- kafka.javaapi.producer.Producer.send(kafka.producer.KeyedMessage) @bci=21 (Interpreted frame)
- com.tmri.cld.impl.kafka.SjKafkaClientUtil.sendMessage(java.lang.String, java.lang.String, byte[]) @bci=40, line=141 (Interpreted frame)
- com.tmri.stream.handle.thread.w.SendLogDataThreadW.run() @bci=356, line=78 (Interpreted frame)
- java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=95, line=1145 (Interpreted frame)
- java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5, line=615 (Interpreted frame)
- java.lang.Thread.run() @bci=11, line=745 (Interpreted frame)

如上所示,我使用 jstack 来获取输出和调试,我已经用 google 搜索了,但仍然没有得到明确的答案,有人可以告诉我 jstack 输出文件中的 IN_NATIVE 状态是什么意思吗?

最佳答案

在某些时候,大多数代码必须与操作系统和“物理”硬件进行交互。 Java 通过 native 代码完成此操作,IN_NATIVE 的 JStack 状态反射(reflect)了这一点 - 它正在运行系统“ native ”代码而不是 Java 代码(例如,将数据写入文件)。查看this question的答案用于 native 代码的定义。

您看到的状态取决于虚拟机,但很可能您正在使用 Hotspot 或类似的东西(OpenJDK、Oracle JDK 等)运行某些东西,因此 following definitions应持有:

  • UNINITIALIZED - Should never happen (missing initialization)
  • NEW - Just starting up, i.e., in process of being initialized
  • IN_NATIVE - Running in native code
  • IN_NATIVE_TRANS - Corresponding transition state
  • IN_VM - Running in VM
  • IN_VM_TRANS - Corresponding transition state
  • IN_JAVA - Running in Java or in stub code
  • BLOCKED - Blocked in vm
  • BLOCKED_TRANS - Corresponding transition state

_TRANS 后缀用于指示线程正在状态之间转换。请注意,未使用状态 IN_JAVA_TRANS 和 NEW_TRANS,因此我已将它们从上面的列表中排除。

关于java - jstack 文件中的 IN_NATIVE 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42203121/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com