设计线程监控代码结构
来源:互联网 发布:php curl get 传参数 编辑:程序博客网 时间:2024/06/05 10:11
线程监控:
/** * 线程状态的监控 * @author dell * */public class Test5 extends RunnableWrapper {@Overridepublic void handler() {System.out.println("xxxxxx");}public static void main(String[] args) {Thread t = new Thread(new Test5());t.start();}}interface ThreadListner {public Object threadStart(Object[] args);public Object threadRunning(Object[] args);public Object threadFinish(Object[] args);public Object threadException(Object[] args);}abstract class RunnableWrapper implements Runnable {private ThreadListner threadListener = null;private static ThreadListner DEFAULT_THREADLISTENER = new ThreadListner() {private String name = Thread.currentThread().getName();@Overridepublic Object threadStart(Object[] args) {System.out.println(name + " start...");return null;}@Overridepublic Object threadRunning(Object[] args) {System.out.println(name + " running...");return null;}@Overridepublic Object threadFinish(Object[] args) {System.out.println(name + " finish...");return null;}@Overridepublic Object threadException(Object[] args) {System.out.println(name + " exception...");return null;}};public RunnableWrapper(ThreadListner threadListener) {this.threadListener = threadListener;}public RunnableWrapper() {this(DEFAULT_THREADLISTENER);}@Overridepublic void run() {try {threadListener.threadStart(null);handler();threadListener.threadFinish(null);} catch (Exception e) {threadListener.threadException(null);}}abstract public void handler();}
0 0
- 设计线程监控代码结构
- 监控线程设计
- 监控远程线程代码
- 浅谈PHP代码设计结构
- 浅谈PHP代码设计结构
- 浅谈PHP代码设计结构
- 浅谈PHP代码设计结构
- 浅谈PHP代码设计结构
- 浅谈PHP代码设计结构
- 线程监控
- 线程监控
- 线程监控
- 线程监控
- 线程监控
- 线程监控
- 线程监控
- 线程监控
- 线程监控
- 安装lr时无法将值Disable Script Debugger 写入注册表
- FastDFS原理系列文章
- WINSOCK.H WINSOCK2.H的区别及函数重复定义的解决方法
- Java Web开发的轻便架构Tapestry5---简介
- SQL Server2008(二)各版本的功能和主要应用范围
- 设计线程监控代码结构
- android源码编译注意事项
- oracle导入导出常用操作命令
- Ubuntu更改MySQL字符集UTF-8,正确显示中文
- 随机产生任意位的字母数字组合
- V4L2框架分析
- Mark一下带边框的表单
- cocos2d-js 热更新代码
- Android自定义控件1