Java每日一题20170327

作者: weknow | 来源:发表于2017-03-27 08:44 被阅读43次

    因简书改版后无法添加扩展链接,20170324问题解析请到公众号查看,问题解析在公众号首发,公众号ID:weknow619。

    package Mar2017;
    
    public class Ques0327 {
    
        public static void main(String[] args) {
            MyThread t1 = new MyThread("t1");
            MyThread t2 = new MyThread("t2");
            t1.start();
            t2.start();
        }
    
    }
    
    class MyThread extends Thread {
        public void output(String s) {
            System.out.println(s);
        }
    
        public void run() {
            for (int i = 0; i < 10; ++i) {
                try {
                    sleep((long)(3000*Math.random()));
                } catch (Exception e) {
                    // TODO: handle exception
                }
                output(getName());
            }
        }
        
        public MyThread(String s) {
            super(s);
        }
    }
    

    今日问题:
    请问主程序运行结果是什么?

    注:weknow团队近期开通并认证了分答,欢迎大家收听,有问题也欢迎到分答来咨询哦,回见您!!


    分答.png

    相关文章

      网友评论

        本文标题:Java每日一题20170327

        本文链接:https://www.haomeiwen.com/subject/wzecottx.html