我在
ttt.start(); //语句A
ttt.xxx(); //语句B
之间加了sleep让出cpu,这样新建的Thread在这段时间就真正执行了。
class TestThread3 extends Thread {
public void run() {
System.out.println("Running");
System.out.println("Done");
} private void xxx() {
System.out.println("In xxx");
} public static void main(String args[]) {
TestThread3 ttt = new TestThread3(); ttt.start(); //语句A try { //look here
Thread.sleep(1000);
}catch (InterruptedException e){
} ttt.xxx(); //语句B
}
}
ttt.start(); //语句A
ttt.xxx(); //语句B
之间加了sleep让出cpu,这样新建的Thread在这段时间就真正执行了。
class TestThread3 extends Thread {
public void run() {
System.out.println("Running");
System.out.println("Done");
} private void xxx() {
System.out.println("In xxx");
} public static void main(String args[]) {
TestThread3 ttt = new TestThread3(); ttt.start(); //语句A try { //look here
Thread.sleep(1000);
}catch (InterruptedException e){
} ttt.xxx(); //语句B
}
}
所以结果是...
http://www.csdn.net/expert/topic/437/437572.shtm吗?谢谢了