2017-02-13 75 views
0
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來獲取輸出和調試,我已經谷歌搜索,仍然沒有得到明確的答案,任何人都可以告訴我什麼IN_NATIVE狀態意味着在jstack輸出文件?IN_NATIVE在jstack文件中意味着什麼?

+0

這意味着在本機代碼中發生異常。 –

+1

[Java線程:解釋正在運行的JVM的線程狀態]的可能重複(http://stackoverflow.com/questions/1827543/java-threads-interpreting-thread-states-of-a-running-jvm) – Seelenvirtuose

回答

2

在某些時候,大多數代碼必須與操作系統和「物理」硬件進行交互。 Java通過本地代碼來實現這一點,IN_NATIVE的JStack狀態反映了這一點 - 它運行的是系統「原生」代碼而不是Java代碼(例如將數據寫入文件)。有關本機代碼的定義,請參閱this question的答案。

您所看到的狀態是VM依賴,但最有可能您正在使用熱點或類似(OpenJDK的,甲骨文JDK等),所以following definitions東西應該持有:

  • UNINITIALIZED - 永遠不應該發生(缺失的初始化)
  • - 剛剛起步的時候,即在過程中被初始化
  • IN_NATIVE - 在本地代碼運行
  • IN_NATIVE_TRANS - 相應的過渡狀態
  • IN_VM - 運行在虛擬機
  • IN_VM_TRANS - 相應的過渡狀態
  • IN_JAVA - 運行在Java或存根代碼
  • BLOCKED - 已鎖定在vm
  • BLOCKED_TRANS - 相應的過渡狀態

的_TRANS後綴用於指示線程狀態之間轉換。請注意,狀態IN_JAVA_TRANS和NEW_TRANS未使用,所以我已將它們排除在上面的列表中。