class MyThread extends Thread{
public void run(){
try {
Thread.currentThread().sleep(3000);// 返回对当前正在执行的线程对象的引用。
} catch (InterruptedException e) {
}
System.out.println("MyThread running");
}
}
public class ThreadTest{
public static void main(String argv[]) {
MyThread t = new MyThread();
t.run();
t.start();
System.out.println("Thread Test");
}
}
运行了还几次.为什么答案都是是这个呢?多线程的话答案不是随机性的么?
MyThread running Thread Test MyThread running
|