Giter Site home page Giter Site logo

globalthreadlistener's Introduction

GlobalThreadLister

监听全局线程状态

目标

  1. 【未实现】开发者自定义线程池大小(目前固定为8)

private static ExecutorService fixedThreadPool = Executors.newFixedThreadPool(5);
懒加载方式可实现

  1. 【已实现】简便将Runnable实现类倒入线程池,并进行监听

GlobalThreadListener.execFixedThreadPool(Runnable run, "线程名称", "描述(可有可无)");

  1. 【已实现】简便获取在该线程池的各个子线程状态

GlobalThreadListener.getThreadProcee();
return:{"【wattingList】":[ ],"【runableList】":[ ],"【terminatedList】":[ ]}

  1. 【未实现】弹小窗(js实现?vue写插件实现?)

鼠标划过,伪类hover触发

  1. 【即将实现】根据线程名称模糊查询线程状态

管理员输入大致被调度的任务,可查询其状态。

  1. 【即将实现】自定义线程状态刷新率

不间断刷新将使得系统负载较大,所以必须要有自定义刷新时间参数,开发者灵活应用

  1. 待续

当前不足

  1. 一个子线程要配合一个监控线程,才能监控该子线程的状态

因为实现Runnable,所以没有返回值。
为解决,另起一个线程:利用实例的引用的内存共享机制,来代表Runnable进度

  1. 监控子线程状态,粒度太大

Future<?> submit = fixedThreadPool.submit(new Runnable);
submit.isDone()

  1. 等待状态和执行状态会有误差,取数算法太简略

一个实例绑定一个子线程,子线程结束,实例(实体类)属性不一定紧接着就更新。

使用说明

  1. 实现一个线程

TestRunnable testRunnable = new TestRunnable(name);//TestRunnable 继承Runnable

  1. 线程倒入线程池

GlobalThreadListener globalThreadListener = GlobalThreadListener.getInstance(); globalThreadListener.execFixedThreadPool(testRunnable, “线程名”, "描述");//将线程执行与线程池,该线程被监听

  1. 获取线程池各个线程状态

GlobalThreadListener.getThreadProcee();//返回GlobalThreadListener监听的所有线程详情(包括等待、执行、终止状态)
GlobalThreadListener.getThreadProceeStatusNum();//返回GlobalThreadListener监听的所有线程详情(包括等待、执行、终止状态)

逻辑

暂不提供,看代码可懂

globalthreadlistener's People

Contributors

szymou avatar

Stargazers

mickelfeng avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.