jmc线程转储

Java Thread dump is list of all the threads active in the JVM.

Java线程转储是JVM中所有活动线程的列表。

Java线程转储 (Java Thread Dump)

Java thread dump is very helpful in analyzing bottlenecks in the application and deadlock situations.

Java线程转储对于分析应用程序和死锁情况下的瓶颈非常有帮助。

Here we will learn multiple ways through which we can generate thread dump for a java program. These instructions are valid for *nix operating systems but in windows the steps might be little different.

在这里,我们将学习可以为Java程序生成线程转储的多种方法。 这些说明适用于* nix操作系统,但在Windows中,步骤可能稍有不同。

  1. VisualVM Profiler: If you are analyzing application for slowness, you must use a profiler. We can generate thread dump for any process using VisualVM profiler very easily. You just need to right click on the running process and click on “Thread Dump” option to generate it.VisualVM Profiler :如果要分析应用程序的运行速度,则必须使用探查器。 我们可以很容易地使用VisualVM Profiler为任何进程生成线程转储。 您只需要右键单击运行的进程,然后单击“ Thread Dump”选项即可生成它。
  2. jstack: Java comes with jstack tool through which we can generate thread dump for a java process. This is a two step process.
    1. Find out the PID of the java process using ps -eaf | grep java command
    2. Run jstack tool as jstack PID to generate the thread dump output to console, you can append thread dump output to file using command “jstack PID >> mydumps.tdump

    jstack :Java附带了jstack工具,通过它我们可以为Java进程生成线程转储。 这是一个两步过程。

    1. 使用ps -eaf | grep java查找Java进程的PID。 ps -eaf | grep java命令
    2. 将jstack工具作为jstack PID运行以将线程转储输出生成到控制台,您可以使用命令“ jstack PID >> mydumps.tdump ”将线程转储输出附加到文件。
  3. We can use kill -3 PID command to generate the thread dump. This is slightly different from other ways to generate thread dump. When kill command is issued, thread dump is generated to the System out of the program. So if it’s a java program with console as system out, the thread dump will get printed on the console. If the java program is a Tomcat server with system out as catalina.out, then thread dump will be generated in the file.我们可以使用kill -3 PID命令生成线程转储。 这与生成线程转储的其他方式稍有不同。 当发出kill命令时,线程转储会从程序中生成到系统。 因此,如果它是带有控制台作为系统输出的Java程序,则线程转储将被打印在控制台上。 如果Java程序是系统输出为catalina.out的Tomcat服务器,则将在文件中生成线程转储。
  4. Java 8 has introduced jcmd utility. You should use this instead of jstack if you are on Java 8 or higher. Command to generate thread dump using jcmd is jcmd PID Thread.print.Java 8引入了jcmd实用程序。 如果您使用的是Java 8或更高版本,则应使用它而不是jstack。 使用jcmd生成线程转储的命令是jcmd PID Thread.print

Above are four different ways to generate thread dump in java. Usually I prefer jstack or jcmd command to generate thread dump and analyze. Note that whatever way you choose, thread dump will always be the same.

上面是用Java生成线程转储的四种不同方法。 通常,我更喜欢使用jstack或jcmd命令来生成线程转储和分析。 请注意,无论选择哪种方式,线程转储都将始终相同。

Java线程转储示例 (Java Thread Dump Example)

In my last post, I explained about java Timer, here is a thread dump generated for the same program.

在上一篇文章中,我解释了有关java Timer的问题 ,这是为同一程序生成的线程转储。

2012-12-26 22:28:39
Full thread dump Java HotSpot(TM) 64-Bit Server VM (23.5-b02 mixed mode):"Attach Listener" daemon prio=5 tid=0x00007fb7d8000000 nid=0x4207 waiting on condition [0x0000000000000000]java.lang.Thread.State: RUNNABLE"Timer-0" daemon prio=5 tid=0x00007fb7d4867000 nid=0x5503 waiting on condition [0x00000001604d9000]java.lang.Thread.State: TIMED_WAITING (sleeping)at java.lang.Thread.sleep(Native Method)at com.journaldev.threads.MyTimerTask.completeTask(MyTimerTask.java:19)at com.journaldev.threads.MyTimerTask.run(MyTimerTask.java:12)at java.util.TimerThread.mainLoop(Timer.java:555)at java.util.TimerThread.run(Timer.java:505)"Service Thread" daemon prio=5 tid=0x00007fb7d482c000 nid=0x5303 runnable [0x0000000000000000]java.lang.Thread.State: RUNNABLE"C2 CompilerThread1" daemon prio=5 tid=0x00007fb7d482b800 nid=0x5203 waiting on condition [0x0000000000000000]java.lang.Thread.State: RUNNABLE"C2 CompilerThread0" daemon prio=5 tid=0x00007fb7d4829800 nid=0x5103 waiting on condition [0x0000000000000000]java.lang.Thread.State: RUNNABLE"Signal Dispatcher" daemon prio=5 tid=0x00007fb7d4828800 nid=0x5003 runnable [0x0000000000000000]java.lang.Thread.State: RUNNABLE"Finalizer" daemon prio=5 tid=0x00007fb7d4812000 nid=0x3f03 in Object.wait() [0x000000015fd26000]java.lang.Thread.State: WAITING (on object monitor)at java.lang.Object.wait(Native Method)- waiting on <0x0000000140a25798> (a java.lang.ref.ReferenceQueue$Lock)at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)- locked <0x0000000140a25798> (a java.lang.ref.ReferenceQueue$Lock)at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:177)"Reference Handler" daemon prio=5 tid=0x00007fb7d4811800 nid=0x3e03 in Object.wait() [0x000000015fc23000]java.lang.Thread.State: WAITING (on object monitor)at java.lang.Object.wait(Native Method)- waiting on <0x0000000140a25320> (a java.lang.ref.Reference$Lock)at java.lang.Object.wait(Object.java:503)at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)- locked <0x0000000140a25320> (a java.lang.ref.Reference$Lock)"main" prio=5 tid=0x00007fb7d5000800 nid=0x1703 waiting on condition [0x0000000106116000]java.lang.Thread.State: TIMED_WAITING (sleeping)at java.lang.Thread.sleep(Native Method)at com.journaldev.threads.MyTimerTask.main(MyTimerTask.java:33)"VM Thread" prio=5 tid=0x00007fb7d480f000 nid=0x3d03 runnable "GC task thread#0 (ParallelGC)" prio=5 tid=0x00007fb7d500d800 nid=0x3503 runnable "GC task thread#1 (ParallelGC)" prio=5 tid=0x00007fb7d500e000 nid=0x3603 runnable "GC task thread#2 (ParallelGC)" prio=5 tid=0x00007fb7d5800000 nid=0x3703 runnable "GC task thread#3 (ParallelGC)" prio=5 tid=0x00007fb7d5801000 nid=0x3803 runnable "GC task thread#4 (ParallelGC)" prio=5 tid=0x00007fb7d5801800 nid=0x3903 runnable "GC task thread#5 (ParallelGC)" prio=5 tid=0x00007fb7d5802000 nid=0x3a03 runnable "GC task thread#6 (ParallelGC)" prio=5 tid=0x00007fb7d5802800 nid=0x3b03 runnable "GC task thread#7 (ParallelGC)" prio=5 tid=0x00007fb7d5803800 nid=0x3c03 runnable "VM Periodic Task Thread" prio=5 tid=0x00007fb7d481e800 nid=0x5403 waiting on condition JNI global references: 116

Thread dump is the list of all the threads, every entry shows information about thread which includes following in the order of appearance.

线程转储是所有线程的列表,每个条目都显示有关线程的信息,其中包括按照出现顺序的信息。

  1. Thread Name: Name of the Thread线程名称线程名称
  2. Thread Priority: Priority of the thread线程优先级线程的优先
  3. Thread ID: Represents the unique ID of the Thread线程ID :代表线程的唯一ID
  4. Thread Status: Provides the current thread state, for example RUNNABLE, WAITING, BLOCKED. While analyzing deadlock look for the blocked threads and resources on which they are trying to acquire lock.线程状态 :提供当前线程状态 ,例如RUNNABLE,WAITING,BLOCKED。 分析死锁时,寻找它们试图获取锁的阻塞线程和资源。
  5. Thread callstack: Provides the vital stack information for the thread. This is the place where we can see the locks obtained by Thread and if it’s waiting for any lock.线程调用堆栈 :提供线程的重要堆栈信息。 在这里,我们可以看到Thread获得的锁以及是否正在等待任何锁。

That’s all for thread dump in java.

这就是Java中的线程转储的全部内容。

翻译自: https://www.journaldev.com/1053/java-thread-dump-visualvm-jstack-kill-3-jcmd

jmc线程转储

jmc线程转储_Java线程转储– VisualVM,jstack,kill -3,jcmd相关推荐

  1. call线程起名字_Java线程的5个使用技巧

    Java线程有哪些不太为人所知的技巧与用法? 萝卜白菜各有所爱.像我就喜欢Java.学无止境,这也是我喜欢它的一个原因.日常工作中你所用到的工具,通常都有些你从来没有了解过的东西,比方说某个方法或者是 ...

  2. java线程触发_java线程

    线程. 状态 新建状态(New): 当用 new 操作符创建一个线程时, 例如 new Thread(r),线程还没有开始运行,此时 线程处在新建状态. 当一个线程处于新生状态时,程序还没有开始运行线 ...

  3. java 线程状态_JAVA线程漫谈:线程状态与状态转换解析

    线程使用方式 JDK线程的顶层抽象是Runnable接口,本质上,线程相关的类都是基于Runnable和Thread实现类实现. JDK API级别有不同的创建线程的方式,但本质是还是基于Runnab ...

  4. java线程分类_Java 线程类别

    Java 线程类别 守护线程和非守护线程 守护线程和非守护线程之前的唯一区别在于:是否阻止JVM的正常退出. JVM正常退出是与异常退出相对的概念,异常退出如调用System.exit(status) ...

  5. idea 线程内存_Java线程池系列之-Java线程池底层源码分析系列(一)

    课程简介: 课程目标:通过本课程学习,深入理解Java线程池,提升自身技术能力与价值. 适用人群:具有Java多线程基础的人群,希望深入理解线程池底层原理的人群. 课程概述:多线程的异步执行方式,虽然 ...

  6. idea 线程内存_Java线程池系列之-Java线程池底层源码分析系列(二)

    课程简介: 课程目标:通过本课程学习,深入理解Java线程池,提升自身技术能力与价值. 适用人群:具有Java多线程基础的人群,希望深入理解线程池底层原理的人群. 课程概述:多线程的异步执行方式,虽然 ...

  7. java线程池返回线程状态_Java线程的不同状态

    java线程池返回线程状态 介绍 在Java中,线程可以具有状态. Thread.State枚举定义Java线程可以具有的不同状态. 该枚举定义了以下值– 新 可运行 已封锁 等候 TIMED_WAI ...

  8. java 线程不足_Java 线程基础知识

    wait() 和notify().notifyAll() 这三个方法用于协调多个线程对共享数据的存取,所以必须在 Synchronized 语句块内使用这三个方法,否则会抛出错 IllegalMoni ...

  9. java线程 睡眠_java线程睡眠问题

    package线程TEST包;publicclassxianchengextendsThread{inti=0;publicxiancheng(Stringname){setName(name);}@ ...

最新文章

  1. C语言实现五子棋游戏(可N*N棋盘)
  2. 各hadoop安装的收集
  3. mysql下拉框回显_下拉框的回显 (修改时候)
  4. maven 入门介绍
  5. Xshell中文乱码问题
  6. java下载zip文件
  7. ios设备开发教程-利用app申请ios开发证书及描述文件
  8. 百度apollo自动驾驶planning代码学习-Apollo/modules/planning/common/Smoother类代码详解
  9. 涉外资(外商)公司股权转让有关问题答疑
  10. 硬盘扇区数据结构分析
  11. 专访光之树创始人张佳辰:围绕产业化和商业化落地,迈向隐私科技
  12. educoder实训平台python基础综合测试答案_智慧职教mooc2020Python程序设计基础章节测试答案...
  13. BDD ROBDD
  14. 生产制造企业仓库管理不到位?ERP系统帮你解决
  15. hdfs Trash回收站配置 java操作trash不生效解决
  16. 易买网更多新闻代码_新闻 | 1022Bewhy结婚等更多资讯
  17. 互联网金融大事件,从泛亚到e租宝敲响的警示钟?
  18. 苹果手机丢了如何通过定位找回?iPhone手机丢失定位找回方法
  19. ac3165 linux驱动_为什么Linux系统没有类似Windows上的还原精灵和影子系统?
  20. 定时关机win10_win10 2004设置笔记本自动关机的方法

热门文章

  1. squid不能启动问题及解决方法
  2. #语音信号处理基础(十一)——梅尔倒谱系数的提取
  3. [转载] 机器学习模型的保存和调用
  4. [USACO5.1] Musical Themes
  5. java中的interface
  6. web app iphone4 iphone5 iphone6 iphone6 Plus响应式布局 适配代码
  7. 团队项目冲刺第二天进度
  8. 微信公众平台消息接口开发之校验签名与消息响应合并
  9. CentOS 6.4 中yum命令安装php5.2.17
  10. C# webbrowser 忽略页面错误