4、jstack查看线程栈信息

Wesley13
• 阅读 1080

1、介绍

利用jps 、 top 、jstack命令找到进程中耗时最大的线程,以及线程状态等等,同时最后还可以显示出死锁的线程 查找:Found one Java-level deadlock 即可

  • 1、jps获得进程号

    4、jstack查看线程栈信息

  • 2、top -Hp 25606 获取本进程中所有线程的CPU耗时性能

    4、jstack查看线程栈信息

  • 3、printf '%x\n' 25608 得到线程的16进制值

    4、jstack查看线程栈信息

  • 4、jstack 25606 | grep 6408

    4、jstack查看线程栈信息

以上就是针对进程中某个线程性能损耗很大的查找方式。

  • 5、如下是jstack命令的结果

      2018-04-03 18:50:16
      Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.101-b13 mixed mode):
    
      "Attach Listener" #147 daemon prio=9 os_prio=0 tid=0x00007f7798001000 nid=0x75d5 waiting on condition [0x0000000000000000]
         java.lang.Thread.State: RUNNABLE
    
      "ConsumerFetcherThread-topic_nimcapture_rzx166-1522750269575-838a87d9-0-23" #146 prio=5 os_prio=0 tid=0x00007f75e4001000 nid=0x5968 runnable [0x00007f767f499000]
         java.lang.Thread.State: RUNNABLE
          at sun.nio.ch.Net.poll(Native Method)
          at sun.nio.ch.SocketChannelImpl.poll(SocketChannelImpl.java:954)
          - locked <0x000000008e6827b8> (a java.lang.Object)
          at sun.nio.ch.SocketAdaptor$SocketInputStream.read(SocketAdaptor.java:204)
          - locked <0x000000008e6827c8> (a java.lang.Object)
          at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:103)
          - locked <0x000000008e682808> (a sun.nio.ch.SocketAdaptor$SocketInputStream)
          at java.nio.channels.Channels$ReadableByteChannelImpl.read(Channels.java:385)
          - locked <0x000000008e6828f8> (a java.lang.Object)
          at org.apache.kafka.common.network.NetworkReceive.readFromReadableChannel(NetworkReceive.java:81)
          at kafka.network.BlockingChannel.readCompletely(BlockingChannel.scala:129)
          at kafka.network.BlockingChannel.receive(BlockingChannel.scala:120)
          at kafka.consumer.SimpleConsumer.liftedTree1$1(SimpleConsumer.scala:86)
          at kafka.consumer.SimpleConsumer.kafka$consumer$SimpleConsumer$$sendRequest(SimpleConsumer.scala:83)
          - locked <0x000000008e682908> (a java.lang.Object)
          at kafka.consumer.SimpleConsumer$$anonfun$fetch$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(SimpleConsumer.scala:132)
          at kafka.consumer.SimpleConsumer$$anonfun$fetch$1$$anonfun$apply$mcV$sp$1.apply(SimpleConsumer.scala:132)
          at kafka.consumer.SimpleConsumer$$anonfun$fetch$1$$anonfun$apply$mcV$sp$1.apply(SimpleConsumer.scala:132)
          at kafka.metrics.KafkaTimer.time(KafkaTimer.scala:33)
          at kafka.consumer.SimpleConsumer$$anonfun$fetch$1.apply$mcV$sp(SimpleConsumer.scala:131)
          at kafka.consumer.SimpleConsumer$$anonfun$fetch$1.apply(SimpleConsumer.scala:131)
          at kafka.consumer.SimpleConsumer$$anonfun$fetch$1.apply(SimpleConsumer.scala:131)
          at kafka.metrics.KafkaTimer.time(KafkaTimer.scala:33)
          at kafka.consumer.SimpleConsumer.fetch(SimpleConsumer.scala:130)
          at kafka.consumer.ConsumerFetcherThread.fetch(ConsumerFetcherThread.scala:108)
          at kafka.consumer.ConsumerFetcherThread.fetch(ConsumerFetcherThread.scala:29)
          at kafka.server.AbstractFetcherThread.processFetchRequest(AbstractFetcherThread.scala:102)
          at kafka.server.AbstractFetcherThread.doWork(AbstractFetcherThread.scala:93)
          at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:63)
    
      "topic_nimcapture_rzx166-1522750269575-838a87d9-leader-finder-thread" #145 prio=5 os_prio=0 tid=0x00007f7648016800 nid=0x5967 waiting on condition [0x00007f767f4da000]
         java.lang.Thread.State: WAITING (parking)
          at sun.misc.Unsafe.park(Native Method)
          - parking to wait for  <0x00000000902d3b60> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
          at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
          at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
          at kafka.consumer.ConsumerFetcherManager$LeaderFinderThread.doWork(ConsumerFetcherManager.scala:61)
          at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:63)
    
      "ConsumerFetcherThread-topic_nimcapture_rzx166-1522750271582-6022ccb2-0-23" #144 prio=5 os_prio=0 tid=0x00007f7644003000 nid=0x5966 runnable [0x00007f767f51b000]
         java.lang.Thread.State: RUNNABLE
          at sun.nio.ch.Net.poll(Native Method)
          at sun.nio.ch.SocketChannelImpl.poll(SocketChannelImpl.java:954)
          - locked <0x000000008e6a7338> (a java.lang.Object)
          at sun.nio.ch.SocketAdaptor$SocketInputStream.read(SocketAdaptor.java:204)
          - locked <0x000000008e6a7348> (a java.lang.Object)
          at sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:103)
          - locked <0x000000008e6a7388> (a sun.nio.ch.SocketAdaptor$SocketInputStream)
          at java.nio.channels.Channels$ReadableByteChannelImpl.read(Channels.java:385)
          - locked <0x000000008e6a7478> (a java.lang.Object)
          at org.apache.kafka.common.network.NetworkReceive.readFromReadableChannel(NetworkReceive.java:81)
          at kafka.network.BlockingChannel.readCompletely(BlockingChannel.scala:129)
          at kafka.network.BlockingChannel.receive(BlockingChannel.scala:120)
          at kafka.consumer.SimpleConsumer.liftedTree1$1(SimpleConsumer.scala:86)
          at kafka.consumer.SimpleConsumer.kafka$consumer$SimpleConsumer$$sendRequest(SimpleConsumer.scala:83)
          - locked <0x000000008e6a7488> (a java.lang.Object)
          at kafka.consumer.SimpleConsumer$$anonfun$fetch$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(SimpleConsumer.scala:132)
          at kafka.consumer.SimpleConsumer$$anonfun$fetch$1$$anonfun$apply$mcV$sp$1.apply(SimpleConsumer.scala:132)
          at kafka.consumer.SimpleConsumer$$anonfun$fetch$1$$anonfun$apply$mcV$sp$1.apply(SimpleConsumer.scala:132)
          at kafka.metrics.KafkaTimer.time(KafkaTimer.scala:33)
          at kafka.consumer.SimpleConsumer$$anonfun$fetch$1.apply$mcV$sp(SimpleConsumer.scala:131)
          at kafka.consumer.SimpleConsumer$$anonfun$fetch$1.apply(SimpleConsumer.scala:131)
          at kafka.consumer.SimpleConsumer$$anonfun$fetch$1.apply(SimpleConsumer.scala:131)
          at kafka.metrics.KafkaTimer.time(KafkaTimer.scala:33)
          at kafka.consumer.SimpleConsumer.fetch(SimpleConsumer.scala:130)
          at kafka.consumer.ConsumerFetcherThread.fetch(ConsumerFetcherThread.scala:108)
          at kafka.consumer.ConsumerFetcherThread.fetch(ConsumerFetcherThread.scala:29)
          at kafka.server.AbstractFetcherThread.processFetchRequest(AbstractFetcherThread.scala:102)
          at kafka.server.AbstractFetcherThread.doWork(AbstractFetcherThread.scala:93)
          at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:63)
    
点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
5个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Stella981 Stella981
3年前
JVM调优之jstack找出最耗cpu的线程并定位代码
jstack可以定位到线程堆栈,根据堆栈信息我们可以定位到具体代码,所以它在JVM性能调优中使用得非常多。下面我们来一个实例找出某个Java进程中最耗费CPU的Java线程并定位堆栈信息,用到的命令有ps、top、printf、jstack、grep。第一步先找出Java进程ID,服务器上的Java应用名称为mrfcenter:root@u
Stella981 Stella981
3年前
KVM调整cpu和内存
一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid
Stella981 Stella981
3年前
Android So动态加载 优雅实现与原理分析
背景:漫品Android客户端集成适配转换功能(基于目标识别(So库35M)和人脸识别库(5M)),导致apk体积50M左右,为优化客户端体验,决定实现So文件动态加载.!(https://oscimg.oschina.net/oscnet/00d1ff90e4b34869664fef59e3ec3fdd20b.png)点击上方“蓝字”关注我
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
11个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这