线程监控
来源:互联网 发布:李腾飞 java 编辑:程序博客网 时间:2024/05/18 01:28
package ww;public class hh { public static void main(String[] args) { // TODO 自动生成的方法存根 MyThread mt=new MyThread("线程MyThread"); //创建线程类MyThread的对象 System.out.println("-------------------------"); System.out.println("线程MyThread 是否处于运动状态:"+mt.t.isAlive());//查看线程的人状态,判断它是后处于运行状态 try{ System.out.println("-------------------------------"); System.out.println("等待线程结束。。。");//等待线程结束 mt.t.join(); } catch(InterruptedException e){ System.out.println("出现错误,线程中断!"); } System.out.println("------------------------------"); System.out.println("线程MyThread 是否处于运动状态:" +mt.t.isAlive()); System.out.println("----------------------------------"); System.out.println("主线程正在退出。。。"); }}class MyThread implements Runnable{ //创建线程类Runnable,实现Runnable接口 String name; Thread t; MyThread(String th){ //创建属于类Thread得线程的对象 name=th; t=new Thread(this,th); System.out.println("创建线程:"+th); t.start();//启动线程 } public void run(){ //重写方法run(),线程休眠一段时间后退出 try{ Thread.sleep(1000); } catch(InterruptedException e){ System.out.println(name+"中断"); } System.out.println("-------------------------------------"); System.out.println(name+" 正在退出。。。"); }}
运行结果:
阅读全文
4 0
- 线程监控
- 线程监控
- 线程监控
- 线程监控
- 线程监控
- 线程监控
- 线程监控
- 线程监控
- 线程监控
- 线程监控
- 监控远程线程代码
- 监控线程设计
- VisualVM监控线程
- WinForm线程监控
- java线程监控
- linux 监控线程命令
- Jstack-线程监控
- jprofiler监控线程-初探
- 数据的异常处理
- Eclipse Git+Gerrit配置及提交流程
- 井下矿工,白书P318LA5131(点双连通分量应用)
- 外部进程嵌入到Qt进程界面
- jquery 实现 图片上传 预览
- 线程监控
- myEclipse更改网站名称
- Xcode工程直接拖
- 171114—程序学习:猜数游戏。
- Beaglebone Black 开发笔记
- #!/bin/bash和#!/bin/sh是什么意思以及区别
- OpenCV.Resize详解
- 优达机器学习:异常值
- 如何对比两个Jar包