arthas 监控线程池相关对象

具体代码,需要设置类的变量,不能设置方法的局部变量

复制代码
package com.xxx.vman.service;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.Semaphore;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Slf4j
public class Test2 {

    private static Semaphore semaphore = new Semaphore(3);
    private static ThreadPoolExecutor executorService = new ThreadPoolExecutor(10,50,60, TimeUnit.SECONDS,new LinkedBlockingQueue<>(200));

    @SneakyThrows
    static void exec(){
        try {
            semaphore.acquire();
            log.info("执行exec方法" + Thread.currentThread().getName());
            Thread.sleep(310);
        } finally {
            semaphore.release();
        }
    }

    @Test
    @SneakyThrows
    public void test(){
        for (;;){
            Thread.sleep(100);
            executorService.execute(() -> exec());
        }
    }

}

arthas监控查看executorService属性命令

ognl -x 3 '@com.xxx.vman.service.Test2@executorService'

查看Test2类对象的属性命令

vmtool -x 3 --action getInstances --className com.xxx.vman.service.Test2 --express 'instances[0]'

相关推荐
清华都得不到的好学生1 分钟前
数据结构->1.稀疏数组,2.数组队列(没有取模),3.环形队列
java·开发语言·数据结构
光影少年1 分钟前
数组去重方法
开发语言·前端·javascript
我命由我123451 分钟前
浏览器的 JS 模块化支持观察记录
开发语言·前端·javascript·css·html·ecmascript·html5
软件开发技术深度爱好者6 分钟前
用python + pillow实现GUI界面图片GUI处理工具
开发语言·python
weyyhdke11 分钟前
基于SpringBoot和PostGIS的省域“地理难抵点(最纵深处)”检索及可视化实践
java·spring boot·spring
ILYT NCTR17 分钟前
【springboot】Spring 官方抛弃了 Java 8!新idea如何创建java8项目
java·spring boot·spring
weixin_4250230018 分钟前
PG JSONB 对应 Java 字段 + MyBatis-Plus 完整实战
java·开发语言·mybatis
bingHHB37 分钟前
金蝶云星空旗舰版 × 赛狐ERP:亚马逊卖家业财一体化的最后一公里
运维·数据库·集成学习
leaves falling1 小时前
C++ string 类:从入门到模拟实现
开发语言·c++
智算菩萨1 小时前
【Tkinter】15 样式与主题深度解析:ttk 主题系统、Style 对象与跨平台样式管理实战
开发语言·python·ui·ai编程·tkinter