Java每日一题20170327

因改版后无法添加扩展链接,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);
    }
}

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

你可能感兴趣的:(Java每日一题20170327)