JAvaスレッド小題

597 ワード


public class Test extends Thread {


    public void run() {
        try{
            Thread.currentThread().sleep(3000);
        }catch(Exception e){}
        
        System.out.println("MyThread running");
    }

    public static void main(String[] args) {

        Test p = new Test();
        p.run();
        p.start();
        System.out.println("test");
    }
}


実行結果の表示
MyThread running
test
MyThread running