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 'instances0'

相关推荐
XS0301062 分钟前
Spring框架
java·后端·spring
风吹心凉3 分钟前
python3基础2026.7.28
开发语言·python
Rabitebla8 分钟前
C++ 内存管理全面复习:从内存分布到 operator new/delete
java·c语言·开发语言·c++·算法·leetcode
xcLeigh8 分钟前
Go入门:main包与main函数的特殊地位
开发语言·后端·golang
Gauss松鼠会9 分钟前
Prometheus 实现 openGauss 的指标监控(二)Prometheus 中添加 openGauss指标
网络·数据库·oracle·prometheus·opengauss·经验总结
Cloud云卷云舒32 分钟前
PolarDB(阿里云)VS HaishanDB(海山数据库,移动云)的AI能力全面对比
数据库·阿里云·ai-native·polardb·haishandb
我是人✓1 小时前
SQL主键与外键
java·数据库
飞翔的馒1 小时前
浏览器缓存之【结构化数据库与缓存】: IndexedDB、Cache storage 和 Storage buckets
数据库·缓存
SelectDB1 小时前
SelectDB search():AI 日志搜索与分析场景的技术能力与实践
数据库