linux 查看java线程与linux线程关系

linux 查看占用cpu高的 java 线程

linux 排查cpu占用100%故障

##java程序

import java.util.Scanner;
public class JavaThreadIDName {

    public static void main(String[] args) {
        Thread t = Thread.currentThread();
        t.setName("laoyoutiao");
        System.out.println("Thread ID: " + t.getId());
        System.out.println("Thread Name: " + t.getName());
        Scanner scanner = new Scanner(System.in);
        String inputString = scanner.nextLine(); // 等待用户输入一行文本
        System.out.println("你输入的是: " + inputString);
    }

}

##linux查看java进程

jps
11409 Jps
10133 JavaThreadIDName

##linux查看java进程最耗cpu资源java线程

top -H -bn 1 -p 10133
top - 18:54:21 up  1:21,  1 user,  load average: 0.09, 0.38, 0.26
Threads:  17 total,   0 running,  17 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.0 us,  0.3 sy,  0.1 ni, 98.3 id,  0.2 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 16424100 total,  9156748 free,  3143220 used,  4124132 buff/cache
KiB Swap:   998396 total,   998396 free,        0 used. 12839668 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
10133 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.00 java
10134 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:01.06 laoyoutiao
10135 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.00 GC Thread#0
10136 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.00 G1 Main Marker
10137 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.00 G1 Conc#0
10138 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.00 G1 Refine#0
10139 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.02 G1 Young RemSet
10140 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.01 VM Thread
10141 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.00 Reference Handl
10142 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.00 Finalizer
10143 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.00 Signal Dispatch
10144 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.00 Service Thread
10145 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.37 C2 CompilerThre
10146 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.76 C1 CompilerThre
10147 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.00 Sweeper thread
10148 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.00 Common-Cleaner
10151 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:00.10 VM Periodic Tas

##linux查看java线程

ps -T -p  10133
  PID  SPID TTY          TIME CMD
10133 10133 pts/19   00:00:00 java
10133 10134 pts/19   00:00:01 laoyoutiao
10133 10135 pts/19   00:00:00 GC Thread#0
10133 10136 pts/19   00:00:00 G1 Main Marker
10133 10137 pts/19   00:00:00 G1 Conc#0
10133 10138 pts/19   00:00:00 G1 Refine#0
10133 10139 pts/19   00:00:02 G1 Young RemSet
10133 10140 pts/19   00:00:01 VM Thread
10133 10141 pts/19   00:00:00 Reference Handl
10133 10142 pts/19   00:00:00 Finalizer
10133 10143 pts/19   00:00:00 Signal Dispatch
10133 10144 pts/19   00:00:00 Service Thread
10133 10145 pts/19   00:00:00 C2 CompilerThre
10133 10146 pts/19   00:00:00 C1 CompilerThre
10133 10147 pts/19   00:00:00 Sweeper thread
10133 10148 pts/19   00:00:00 Common-Cleaner
10133 10151 pts/19   00:00:09 VM Periodic Tas

##linux查看java堆栈

jstack 10133
2024-05-16 09:31:15
Full thread dump OpenJDK 64-Bit Server VM (11.0.21-internal+0-adhoc.yym.jdk11u-master mixed mode):

Threads class SMR info:
_java_thread_list=0x00007f83c40021f0, length=10, elements={
0x00007f8408031800, 0x00007f8408312000, 0x00007f8408315000, 0x00007f8408350000,
0x00007f8408352800, 0x00007f8408355000, 0x00007f8408357800, 0x00007f840835a000,
0x00007f84083af800, 0x00007f83c4001000
}
_java_thread_list_alloc_cnt=15, _java_thread_list_free_cnt=14, _java_thread_list_max=11, _nested_thread_list_max=0
_tlh_cnt=55480, _tlh_times=3, avg_tlh_time=0.00, _tlh_time_max=1
_deleted_thread_cnt=2, _deleted_thread_times=0, avg_deleted_thread_time=0.00, _deleted_thread_time_max=0
_delete_lock_wait_cnt=0, _delete_lock_wait_max=0
_to_delete_list_cnt=0, _to_delete_list_max=1

"laoyoutiao" #1 prio=5 os_prio=0 cpu=1062.77ms elapsed=52744.36s tid=0x00007f8408031800 nid=0x2796 runnable  [0x00007f8411459000]
   java.lang.Thread.State: RUNNABLE
   JavaThread state: _thread_in_native
Thread: 0x00007f8408031800  [0x2796] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0
   JavaThread state: _thread_in_native
	at java.io.FileInputStream.readBytes(java.base/Native Method)
	at java.io.FileInputStream.read(java.base/FileInputStream.java:279)
	at java.io.BufferedInputStream.read1(java.base/BufferedInputStream.java:290)
	at java.io.BufferedInputStream.read(java.base/BufferedInputStream.java:351)
	- locked <0x000000071510dfa8> (a java.io.BufferedInputStream)
	at sun.nio.cs.StreamDecoder.readBytes(java.base/StreamDecoder.java:284)
	at sun.nio.cs.StreamDecoder.implRead(java.base/StreamDecoder.java:326)
	at sun.nio.cs.StreamDecoder.read(java.base/StreamDecoder.java:178)
	- locked <0x0000000714916f58> (a java.io.InputStreamReader)
	at java.io.InputStreamReader.read(java.base/InputStreamReader.java:181)
	at java.io.Reader.read(java.base/Reader.java:189)
	at java.util.Scanner.readInput(java.base/Scanner.java:882)
	at java.util.Scanner.findWithinHorizon(java.base/Scanner.java:1796)
	at java.util.Scanner.nextLine(java.base/Scanner.java:1649)
	at JavaThreadIDName.main(JavaThreadIDName.java:10)

"Reference Handler" #2 daemon prio=10 os_prio=0 cpu=0.22ms elapsed=52744.24s tid=0x00007f8408312000 nid=0x279d waiting on condition  [0x00007f83e844a000]
   java.lang.Thread.State: RUNNABLE
   JavaThread state: _thread_blocked
Thread: 0x00007f8408312000  [0x279d] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0
   JavaThread state: _thread_blocked
	at java.lang.ref.Reference.waitForReferencePendingList(java.base/Native Method)
	at java.lang.ref.Reference.processPendingReferences(java.base/Reference.java:241)
	at java.lang.ref.Reference$ReferenceHandler.run(java.base/Reference.java:213)

"Finalizer" #3 daemon prio=8 os_prio=0 cpu=1.21ms elapsed=52744.24s tid=0x00007f8408315000 nid=0x279e in Object.wait()  [0x00007f83e8349000]
   java.lang.Thread.State: WAITING (on object monitor)
   JavaThread state: _thread_blocked
Thread: 0x00007f8408315000  [0x279e] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0
   JavaThread state: _thread_blocked
	at java.lang.Object.wait(java.base/Native Method)
	- waiting on <0x0000000715109008> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(java.base/ReferenceQueue.java:155)
	- waiting to re-lock in wait() <0x0000000715109008> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(java.base/ReferenceQueue.java:176)
	at java.lang.ref.Finalizer$FinalizerThread.run(java.base/Finalizer.java:170)

"Signal Dispatcher" #4 daemon prio=9 os_prio=0 cpu=0.54ms elapsed=52744.17s tid=0x00007f8408350000 nid=0x279f runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   JavaThread state: _thread_blocked
Thread: 0x00007f8408350000  [0x279f] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0
   JavaThread state: _thread_blocked

"Service Thread" #5 daemon prio=9 os_prio=0 cpu=0.05ms elapsed=52744.17s tid=0x00007f8408352800 nid=0x27a0 runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   JavaThread state: _thread_blocked
Thread: 0x00007f8408352800  [0x27a0] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0
   JavaThread state: _thread_blocked

"C2 CompilerThread0" #6 daemon prio=9 os_prio=0 cpu=456.01ms elapsed=52744.17s tid=0x00007f8408355000 nid=0x27a1 waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   JavaThread state: _thread_blocked
Thread: 0x00007f8408355000  [0x27a1] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0
   JavaThread state: _thread_blocked
   No compile task

"C1 CompilerThread0" #9 daemon prio=9 os_prio=0 cpu=865.46ms elapsed=52744.17s tid=0x00007f8408357800 nid=0x27a2 waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   JavaThread state: _thread_blocked
Thread: 0x00007f8408357800  [0x27a2] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0
   JavaThread state: _thread_blocked
   No compile task

"Sweeper thread" #10 daemon prio=9 os_prio=0 cpu=0.04ms elapsed=52744.17s tid=0x00007f840835a000 nid=0x27a3 runnable  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   JavaThread state: _thread_blocked
Thread: 0x00007f840835a000  [0x27a3] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0
   JavaThread state: _thread_blocked

"Common-Cleaner" #11 daemon prio=8 os_prio=0 cpu=24.27ms elapsed=52744.12s tid=0x00007f84083af800 nid=0x27a4 in Object.wait()  [0x00007f83cb3fa000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
   JavaThread state: _thread_blocked
Thread: 0x00007f84083af800  [0x27a4] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0
   JavaThread state: _thread_blocked
	at java.lang.Object.wait(java.base/Native Method)
	- waiting on <0x0000000715128de8> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(java.base/ReferenceQueue.java:155)
	- waiting to re-lock in wait() <0x0000000715128de8> (a java.lang.ref.ReferenceQueue$Lock)
	at jdk.internal.ref.CleanerImpl.run(java.base/CleanerImpl.java:148)
	at java.lang.Thread.run(java.base/Thread.java:829)
	at jdk.internal.misc.InnocuousThread.run(java.base/InnocuousThread.java:161)

"Attach Listener" #12 daemon prio=9 os_prio=0 cpu=0.15ms elapsed=0.21s tid=0x00007f83c4001000 nid=0x2cca waiting on condition  [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
   JavaThread state: _thread_blocked
Thread: 0x00007f83c4001000  [0x2cca] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0
   JavaThread state: _thread_blocked

"VM Thread" os_prio=0 cpu=1264.74ms elapsed=52744.28s tid=0x00007f84082fb800 nid=0x279c runnable  

"GC Thread#0" os_prio=0 cpu=569.98ms elapsed=52744.36s tid=0x00007f8408051000 nid=0x2797 runnable  

"G1 Main Marker" os_prio=0 cpu=4.53ms elapsed=52744.35s tid=0x00007f84080b1800 nid=0x2798 runnable  

"G1 Conc#0" os_prio=0 cpu=0.03ms elapsed=52744.35s tid=0x00007f84080b3800 nid=0x2799 runnable  

"G1 Refine#0" os_prio=0 cpu=4.80ms elapsed=52744.35s tid=0x00007f84081d9800 nid=0x279a runnable  

"G1 Young RemSet Sampling" os_prio=0 cpu=2482.68ms elapsed=52744.35s tid=0x00007f84081db800 nid=0x279b runnable  
"VM Periodic Task Thread" os_prio=0 cpu=10019.83ms elapsed=52743.55s tid=0x00007f84086ba000 nid=0x27a7 waiting on condition  

JNI global refs: 9, weak refs: 0

##

ps显示pid和java nid 计算。可以使用计算器转换16进制

10134 yym       20   0 6895436  98148  28224 S  0.0  0.6   0:01.06 laoyoutiao

"laoyoutiao" #1 prio=5 os_prio=0 cpu=1062.77ms elapsed=52744.36s tid=0x00007f8408031800 nid=0x2796 runnable  [0x00007f8411459000]

由此就可以查看哪个java线程最耗cpu资源。从而解决cpu 100%问题。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/633203.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

golang创建式设计模式---工厂模式

创建式设计模式—工厂模式 目录导航 创建式设计模式---工厂模式1)什么是工厂模式2)使用场景3)实现方式4)实践案例5)优缺点分析 1)什么是工厂模式 工厂模式(Factory Method Pattern)是一种设计模式&#xff0c;旨在创建对象时&#xff0c;将对象的创建与使用进行分离。通过定义…

以太坊(2)——共识机制与挖矿算法

共识机制 ETH采用的是基于GHOST协议的共识机制 "GHOST"&#xff08;Greedy Heaviest-Observed Sub-Tree&#xff09;共识机制&#xff0c;它是以太坊使用的一种改进的区块链共识算法。GHOST共识机制旨在提高链的安全性和效率&#xff0c;通过考虑非主链区块的贡献&…

kubectl详解

文章目录 kubectl详解一、陈述式管理1、陈述式资源管理方法2、k8s相关信息查看2.1 查看版本信息2.1.1 查看资源对象简写2.1.2 查看集群信息2.1.3 配置kubectl自动补全2.1.4 查看日志 2.2 基本信息查看2.2.1 查看集群状态2.2.2 查看命名空间 2.3 命名空间操作2.3.1 查看default命…

CDN用户平台安装说明

CDN用户平台安装说明 登录管理员系统 在”系统设置” – “高级设置” – “用户节点”中点击”添加节点” 如果所示&#xff1a; 节点名称 - 可以任意填写 进程监听端口 - 启动用户节点后&#xff0c;进程所监听的端口&#xff0c;通常是HTTP 80或者HTTPS 443&#xff0c;…

html 段落与排版标记 Web前端开发技术、详细文章(例如)

段落与排版标记 网页的外观是否美观&#xff0c;很大程度上取决于其排版。在页面中出现大段的文字&#xff0c;通常采用分段进行规划&#xff0c;对换行也有极其严格的划分。本节从段落的细节设置入手&#xff0c;利用段落与排版标记自如地处理大段的文字。 段落p标记 在HTM…

Spring Cloud Gateway 网关

一. 什么是网关&#xff08;Gateway&#xff09; 网关就是一个网络连接到另一个网络的关口。 在同一个项目或某一层级中&#xff0c;存在相似或重复的东西&#xff0c;我们就可以将这些相似重复的内容统一提取出来&#xff0c;向前或向后抽象成单独的一层。这个抽象的过程就是…

Linux磁盘高级操作

RAID RAID存储系统是一种数据存储虚拟化技术&#xff0c;它将多个物理磁盘驱动器组合成一个或多个逻辑单元&#xff0c;以提供数据冗余和/或提高性能。 1. RAID 0 无奇偶校验与冗余&#xff08;磁盘容错&#xff09;的条带存储&#xff08;带区卷/条带卷&#xff09; 由两块…

Linux-文件或目录权限

在使用 ll 时&#xff0c;可以查看文件夹内容的详细信息&#xff0c;信息的第1位表示类型&#xff0c;具体信息如下&#xff1a; 类型说明-普通文件d文件夹b块设备文件c字符设备文件p管道文件s套接口文件 第2-10位表示权限&#xff0c; 举例&#xff1a;rwxr-xr-x 类型说明r…

简单快捷的图片格式转换工具:认识webp2jpg-online

经常写博客或记笔记的朋友们可能会碰到图床不支持的图片格式或图片太大需要压缩的情况。通常&#xff0c;我们会在浏览器中搜索在线图片格式转换器&#xff0c;但这些转换器往往伴有烦人的广告或要求登录&#xff0c;并且支持的转换格式有限。最近&#xff0c;我在浏览 GitHub …

java8总结

java8总结 java8新特性总结1. 行为参数化2. lambda表达式2.1 函数式接口2.2 函数描述符 3. Stream API3.1 付诸实践 java8新特性总结 行为参数化lambda表达式Stream Api 1. 行为参数化 定义&#xff1a;行为参数化&#xff0c;就是一个方法接受多个不同的行为作为参数&#x…

HiWoo Box边缘计算网关

​在数字化浪潮汹涌的今天&#xff0c;边缘计算网关成为了连接物理世界与数字世界的桥梁&#xff0c;其重要性日益凸显。HiWoo Box&#xff0c;作为一款功能强大的边缘计算网关&#xff0c;不仅具备了传统网关的基本功能&#xff0c;更在数据采集、处理、传输等方面展现出了卓越…

岛屿问题刷题

200. 岛屿数量 - 力扣&#xff08;LeetCode&#xff09; class Solution {public int numIslands(char[][] grid) {int n grid.length;//grid行数int m grid[0].length;//grid列数int res 0;for(int r 0;r<n;r){for(int c0;c<m;c){if(grid[r][c]1){dfs(grid,r,c);res…

Web Server项目实战3-Web服务器简介及HTTP协议

Web Server&#xff08;网页服务器&#xff09; 一个 Web Server 就是一个服务器软件&#xff08;程序&#xff09;&#xff0c;或者是运行这个服务器软件的硬件&#xff08;计算机&#xff09;。其主要功能是通过 HTTP 协议与客户端&#xff08;通常是浏览器&#xff08;Brow…

面试八股之MySQL篇5——主从同步原理篇

&#x1f308;hello&#xff0c;你好鸭&#xff0c;我是Ethan&#xff0c;一名不断学习的码农&#xff0c;很高兴你能来阅读。 ✔️目前博客主要更新Java系列、项目案例、计算机必学四件套等。 &#x1f3c3;人生之义&#xff0c;在于追求&#xff0c;不在成败&#xff0c;勤通…

绿色智能:AI机器学习在环境保护中的深度应用与实践案例

&#x1f9d1; 博主简介&#xff1a;阿里巴巴嵌入式技术专家&#xff0c;深耕嵌入式人工智能领域&#xff0c;具备多年的嵌入式硬件产品研发管理经验。 &#x1f4d2; 博客介绍&#xff1a;分享嵌入式开发领域的相关知识、经验、思考和感悟&#xff0c;欢迎关注。提供嵌入式方向…

CSS transform 三大属性 rotate、scale、translate

transform 浏览器支持定义和用法translate位移函数rotate旋转函数scale缩放函数 浏览器支持 表格中的数字表示支持该属性的第一个浏览器版本号。 紧跟在 -webkit-, -ms- 或 -moz- 前的数字为支持该前缀属性的第一个浏览器版本号。 定义和用法 transform 属性向元素应用 2D…

音视频安卓主板记录仪手持终端定制开发_基于MT6762平台解决方案

音视频安卓主板采用了基于MT6762高性能处理器芯片的设计&#xff0c;其中包括4个主频高达2.0GHz的Cortex-A53核心和4个主频1.5GHz的Cortex-A53高效聚焦核心&#xff0c;可提供无比流畅的体验。搭载Android 12操作系统&#xff0c;系统版本进行了全新的优化&#xff0c;进一步确…

新火种AI|净利润上升628%,英伟达财报说明AI热潮还将持续

作者&#xff1a;一号 编辑&#xff1a;美美 AI大潮仍未放缓&#xff0c;英伟达再次超越预期。 今天凌晨&#xff0c;全球AI算力芯片龙头&#xff0c;被称为“AI时代卖铲人”的英伟达&#xff0c;正式公布了截至2024年4月28日的2025财年第一财季财报&#xff0c;其中第一财季…

Linux:top命令的每一列的具体含义

Linux&#xff1a;top命令的每一列的具体含义 文章目录 Linux&#xff1a;top命令的每一列的具体含义图片显示top命令的概念语法显示字段的含义顶部字段第二行第三行第四行第五行每列字段的含义 图片显示 top命令的概念 top命令上一个常用的Linux命令行工具&#xff0c;用于实…

医院是自建档案室还是档案寄存好呢

医院可以选择自建档案室或档案寄存&#xff0c;具体选择取决于医院的需求和资源。 自建档案室意味着医院会拥有自己的档案空间和设施&#xff0c;可以更方便地管理和保管档案。这种方式可以确保医院对档案的访问和控制有更多的自主权&#xff0c;同时也能够根据医院的需求进行档…