标签:线程
package cn.thread;
public class ThreadSleep {
/**
* 线程的调度-休眠
*
*/
public static void main(String[] args) {
ThreadSleep sleep = new ThreadSleep();
Thread t1 = sleep.new MyThread1();
Thread t2 = new Thread(sleep.new Runnable1());
t1.start();
t2.start();
}
class MyThread1 extends Thread {
@Override
public void run() {
for (int i = 0; i < 4; i++) {
System.out.println("线程1第" + i + "次执行");
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
class Runnable1 implements Runnable {
public void run() {
for (int i = 0; i < 4; i++) {
System.out.println("线程2第" + i + "次执行");
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}标签:线程
原文地址:http://blog.csdn.net/u013777676/article/details/46004705