ITPub博客

首页 > 数据库 > 数据库开发技术 > arthas进阶thread命令视频演示

arthas进阶thread命令视频演示

原创 数据库开发技术 作者:FunTester 时间:2020-04-23 08:16:39 0 删除 编辑

之前分享过arthas的基础使用和快捷入门,自己打算把这个系列继续做下去。工具还是非常强大的,适用范围也非常的广。在性能测试和性能分析以及故障诊断方面有着非常大的应用。然后和这个工具和JVM的一些工具搭配起来会非常非常地有用!如果是想做Java服务端的性能测试的话,我觉得这一定是一个绕不过去的一个神器。

你今天给大家分享啊,arthas进阶中,比较重要的命令thread。它主要负责去查看嗯Java虚拟机里面关于线程的信息。比如:当前JVM虚拟机的线程概况、线程的运行状态、线程的优先级等等。当然他也可以查看线程的具体信息,比如:线程的堆栈、线程使用CPU的情况线程的死锁,线程使用对象锁或者说是类锁的状态。还可以根据线程的运行状态进行分类统计,你也可以通过设置统计间隔来达到。对线程的运行消耗CPU的情况的一个监控。

官方文档地址如下:https://alibaba.github.io/arthas/

arthas进阶thread命令

由于我并没有使用官方的演示Demo,自己随手写了一个,下面是代码:

package com.fun

import com.fun.frame.httpclient.FanLibrary

class sdsync extends FanLibrary {

    public static void main(String[] args) {

        Thread thread1 = new Thread({
            1000.times {
                test(it + 10000)
            }
        })
        Thread thread2 = new Thread({
            1000.times {
                test(it + 20000)
            }
        })
        Thread thread3 = new Thread({
            1000.times {
                test(it + 30000)
            }
        })
        Thread thread4 = new Thread({
            1000.times {
                test(it + 40000)
            }
        })
        thread1.start()
        thread2.start()
        thread3.start()
        thread1.join()
        thread2.join()
        thread3.join()

        testOver()
    }

    static void test(int i) {
        output(Thread.currentThread().getName() + "开始!----$i")
        synchronized (sdsync.class) {
            sleep(1000)
        }
        output(Thread.currentThread().getName() + "结束!-----${i}")
    }
}


  • 郑重声明:“FunTester”首发,欢迎关注交流,禁止第三方转载。

技术类文章精选

无代码文章精选

原文作者:FunTester;如有侵权,请联系管理员删除。

请登录后发表评论 登录
全部评论

注册时间:2019-07-07

  • 博文量
    1037
  • 访问量
    421240