练习1

 

package zuoYe02;

public class News {

    public static void main(String[] args) {

        Thread t1 = new Thread() {

            public void run() {

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

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

                }

            }

        };
        Thread t2 = new Thread() {

            public void run() {
                
                for (int i = 1; i <= 20; i++) {
                    System.out.println(i + ".你好,来自线程" + Thread.currentThread().getName());
                    
                }
                
            }
        };

        t1.start();
        t2.start();
    }
}

 

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