public class MyThread1 extends Thread { public MyThread1(String name) { super(name); } public void run() { System.out.println(this.getName()); } public static void main(String[] args) { Thread t1 = new MyThread1("阿三"); t1.start(); } } public class MyThread implements Runnable { private String name; public MyThread(String name) { this.name = name; } @Override public void run() { System.out.println(name); } public static void main(String[] args) { Thread tt1 = new Thread(new MyThread("张三")); tt1.start(); } }
a.join(); System.out.print("End"); //等待线程a结束后再打印出“End”
版权声明:本文为原创文章,转载请注明转自Clement-Xu的csdn博客。
原文地址:http://blog.csdn.net/clementad/article/details/47027425