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

相关推荐
f***68608 分钟前
【SpringBoot篇】详解Bean的管理(获取bean,bean的作用域,第三方bean)
java·spring boot·后端
likuolei1 小时前
Eclipse 快捷键
java·ide·eclipse
w***4242 小时前
【MySQL】复合查询
数据库·mysql
胡萝卜3.02 小时前
掌握C++ map:高效键值对操作指南
开发语言·数据结构·c++·人工智能·map
q***01773 小时前
【MySQL】表的基本操作
数据库·mysql·oracle
电子_咸鱼3 小时前
【STL string 全解析:接口详解、测试实战与模拟实现】
开发语言·c++·vscode·python·算法·leetcode
budingxiaomoli3 小时前
存储过程和触发器
数据库
q***12533 小时前
PostgreSQL_安装部署
数据库·postgresql
q***48253 小时前
mysql用户名怎么看
数据库·mysql
夏日玲子3 小时前
【Redis】Redis常用命令合集
数据库·redis·缓存