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 小时前
JavaScript 微任务与宏任务完全指南
开发语言·javascript·ecmascript
Elastic 中国社区官方博客2 小时前
Elasticsearch:使用 Agent Builder 的 A2A 实现 - 开发者的圣诞颂歌
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
2301_816660212 小时前
PHP怎么处理Eloquent Attribute Inference属性推断_Laravel从数据自动推导类型【操作】
jvm·数据库·python
chools2 小时前
【AI超级智能体】快速搞懂工具调用Tool Calling 和 MCP协议
java·人工智能·学习·ai
知行合一。。。2 小时前
Python--05--面向对象(属性,方法)
android·开发语言·python
李白你好2 小时前
TongWeb EJB 反序列化生成工具(Java-Chain 插件)
java·安全
青梅橘子皮2 小时前
C语言---指针的应用以及一些面试题
c语言·开发语言·算法
qq_372154233 小时前
Go 中自定义类型与基础类型的显式转换规则详解
jvm·数据库·python
浅时光_c3 小时前
3 shell脚本编程
linux·开发语言·bash
Evand J3 小时前
【三维轨迹目标定位,CKF+RTS,MATLAB程序】基于CKF与RTS平滑的三维非线性目标跟踪(距离+方位角+俯仰角)
开发语言·matlab·目标跟踪