创建线程的两种方式
来源:互联网 发布:直播网络公会 编辑:程序博客网 时间:2024/05/17 00:51
package cn.cblue.heima2;
import java.util.Date;
/**
* @Description: 创建线程的两种方式
* @author huangzjb cblue2013@126.com
* @Company Digital China
* @date 2014-5-28 下午04:16:40
* @version 1.0
*/
public class TraditionalThread {
public static void main(String[] args) {
// 第一种:继承Thread类
new Thread() {
public void run() {
}
}.start();
// 第二种:实现Runnable接口
new Thread(new Runnable() {
public void run() {
System.out.println(Thread.currentThread().getName());
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(new Date().getSeconds());
}
}
}).start();
}
}
import java.util.Date;
/**
* @Description: 创建线程的两种方式
* @author huangzjb cblue2013@126.com
* @Company Digital China
* @date 2014-5-28 下午04:16:40
* @version 1.0
*/
public class TraditionalThread {
public static void main(String[] args) {
// 第一种:继承Thread类
new Thread() {
public void run() {
}
}.start();
// 第二种:实现Runnable接口
new Thread(new Runnable() {
public void run() {
System.out.println(Thread.currentThread().getName());
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(new Date().getSeconds());
}
}
}).start();
}
}
0 0
- 创建线程两种方式的比较
- java 创建线程 的两种方式
- 创建线程两种方式的比较
- 创建线程的两种方式
- 创建线程的两种方式
- 多线程 创建线程的两种方式
- 创建线程的两种方式
- Java线程创建的两种方式
- 创建线程的两种方式
- 创建线程的两种方式
- 创建线程的两种方式。
- java创建线程的两种方式
- 线程的两种创建方式
- java创建线程的两种方式
- java线程的两种创建方式
- Java创建线程的两种方式
- 线程创建的两种方式
- 创建线程的两种方式
- Oracle中rownum的使用
- oracle之系统预定义角色
- Java串口通信
- Snow.obj : error LNK2005: "unsigned char * __cdecl LoadBitmapFile(char *,struct tagBITMAPINFOHEADE
- 个人股后过几年
- 创建线程的两种方式
- 如何做好诚信通推广
- java中如何判定两个对象属于同一类
- Mybatis 一对多(OneToOne)关系映射
- 工作中常常会用到的git命令
- Jetty:基本功能介绍
- oracle over的用法
- C. Ryouko's Memory Note
- android 面试题