非常初级,废话不多说,上源码:
public class Test { public static void main(String[] args) {
MyRun my = new MyRun();
Thread td = new Thread(my);
td.start();
System.out.println("this is from main");
}
}
class MyRun implements Runnable{ @Override
public void run() {
System.out.println("this is from myrun");
}
}=========================================
执行结果:
this is from main
this is from myrun问题是,明明td.start()在先,为什么不先执行,为什么不是下面的结果:
this is from myrun
this is from main拜谢!!!!
public class Test { public static void main(String[] args) {
MyRun my = new MyRun();
Thread td = new Thread(my);
td.start();
System.out.println("this is from main");
}
}
class MyRun implements Runnable{ @Override
public void run() {
System.out.println("this is from myrun");
}
}=========================================
执行结果:
this is from main
this is from myrun问题是,明明td.start()在先,为什么不先执行,为什么不是下面的结果:
this is from myrun
this is from main拜谢!!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货