练习2

 

 

package zuoYe02;

public class Run1 implements Runnable{
    @Override
    public void run() {
        // TODO Auto-generated method stub

        for (int i = 1; i <= 20; i++) {

            System.out.println(i + ".你好,来自线程" + Thread.currentThread().getName());
        }
    }

}

 

package zuoYe02;

public class Test {

    public static void main(String[] args) {
        
        Run1 r = new Run1();
        
    
        
        Thread t1 = new Thread(r,"线程一");
        
        Thread t2 = new Thread(r,"线程二");
        
        
        t1.start();
        t2.start();
        
    }
    
    
}

 

posted @ 2019-08-06 14:23  AxeBurner  阅读(75)  评论(0编辑  收藏  举报