A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© taoaisheng 中级黑马   /  2015-8-20 18:51  /  375 人查看  /  2 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

以下程序运行的结果为()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public class Example extends Thread{
     @Override
     public void run(){
        try{
             Thread.sleep(1000);
             }catch (InterruptedException e){
             e.printStackTrace();
             }
             System.out.print("run");
     }
     public static void main(String[] args){
             Example example=new Example();
             example.run();
             System.out.print("main");
     }
}

run main
main run
main
run
不能确定
哪位大神帮忙解决解决,尤其是这样的程序题,不知道该怎么去看流程题,感觉自己看不懂,哪位大神能帮忙给点好的方法和建议啊,万分感谢。

2 个回复

倒序浏览
run  main
这里只调用了example类中的run方法,故主线程休眠10S后打印run 然后打印main.并没有开启其他的线程
回复 使用道具 举报
你没有启动其他线程。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马