JavaSE 基础 第55节 实现Runnable接口创建线程

2016-07-01

package com.java1995;

public class RunnableDemo {
    
    public static void main(String[] args) {
        MyThread mt=new MyThread();
        Thread t=new Thread(mt);
        t.start();
        
        for(int i=0;i<10;i++){
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println("主线程"+i);
        }
    }

}

 

package com.java1995;

public class RunnableDemo {
    
    public static void main(String[] args) {
        MyThread mt=new MyThread();
        Thread t=new Thread(mt);
        t.start();
        
        for(int i=0;i<10;i++){
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            System.out.println("主线程"+i);
        }
    }

}

 

posted @ 2016-07-01 21:10  岑亮  阅读(108)  评论(0编辑  收藏  举报