多线程流程
来源:互联网 发布:js encode decode 编辑:程序博客网 时间:2024/05/24 15:42
/**
*<br>方法说明:构造器。实际线程,并启动这个线程。
*<br>输入参数:
*<br>返回类型:
*/
twothread() {
//获取当前的线程
Thread t1 =Thread.currentThread();
t1.setName("The first main thread");
System.out.println("The running thread:" + t1.getName());
//通过将本类(Runnable接口)和名称构造一个线程
Thread t2 = new Thread(this,"the second thread");
System.out.println("creat another thread"+"\t"+t2.getName());
//启动线程
t2.start();
try {
System.out.println("this thread will sleep"+"\t"+Thread.currentThread().getName());
Thread.sleep(3000);
}catch (InterruptedException e) {
System.out.println("first thread has wrong");
}
System.out.println("first thread exit");
}
/**
*<br>方法说明:线程主体。实现run方法。
*<br>输入参数:
*<br>返回类型:
*/
public void run() {
try {
for (int i=0;i<5;i++) {
System.out.println("Sleep time for thread :"+Thread.currentThread().getName());
Thread.sleep(1000);
}
} catch (InterruptedException e) {
System.out.println("thread has wrong");
}
System.out.println("second thread exit");
}
/**
*<br>方法说明:主方法
*<br>输入参数:
*<br>返回类型:
*/
public static void main(String args[]) {
new twothread();
}
- 多线程流程
- ffmpeg多线程解码流程
- OpenHEVC多线程解码流程
- ccflow 的子流程与多线程流程
- [Java] oscache 多线程 工作流程的分析
- 浅谈Java多线程程序设计初步详细流程
- Android多线程-AsyncTask工作流程(源码)
- Java多线程——6 并发流程控制CountDownLatch、CycliBarrier
- thrift non-blocking server在多线程下的处理流程
- 多线程并发流程控制之dispatch_group 有关函数
- 多线程并发流程控制之dispatch_group 有关函数
- liunx c实现http多线程下载1(总体流程)
- 流程
- 流程
- 流程
- 流程
- 流程
- 流程
- android ViewPager动态加载问题
- C#操作数据库的常用公共方法!
- Android适配器之-----BaseAdapter(帮助文档)
- 有序表的查找(折半查找)
- C++异常处理
- 多线程流程
- javase_14(字节流)
- oracle实用工具:oradebug
- SAP Performance浅析
- 在网页中加入视频文件
- Ice中Monitor的使用
- doc命令大全(经典)
- C# WinForm中进度条的实现方法
- 基本SQL语句