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

相关推荐
白露与泡影几秒前
Spring事件机制完全指南:解耦利器与实战
java·后端·spring
DYS_房东的猫2 分钟前
《 C++ 零基础入门教程》第10章:C++20 核心特性 —— 编写更现代、更优雅的 C++
java·c++·c++20
好好沉淀2 分钟前
Spring AI Alibaba
java·人工智能·spring
老邓计算机毕设8 分钟前
SSM学期分析与学习行为分析系统c8322(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面
数据库·学习·ssm 框架·学期分析·学习行为分析
学Linux的语莫13 分钟前
python创建redis连接池
数据库·redis·缓存
写代码的【黑咖啡】14 分钟前
Python 中的 Requests 库:轻松进行 HTTP 请求
开发语言·python·http
BD_Marathon15 分钟前
MyBatis各种查询功能
java·开发语言·mybatis
研☆香16 分钟前
JavaScript 特点介绍
开发语言·javascript·ecmascript
Howrun77719 分钟前
虚幻引擎_AController_APlayerController_AAIController
开发语言·c++·游戏引擎·虚幻
雪人.21 分钟前
Spring常见面试题(2026版30道面试题)
java·后端·spring