插队:
在t2中, t1.join() t1执行完之后再执行t2
t1.join(1) 插队1毫秒, 时间过后 t1 t2两条线程再随机执行
public class demon5_join { public static void main(String[] args) { Thread t1 = new Thread(){ public void run() { for (int i = 0; i < 10; i++) { System.out.println(this.getName() + "...aaaa"); } } }; Thread t2 = new Thread(){ public void run() { for (int i = 0; i < 10; i++) { if (i==2) { try { t1.join(); } catch (InterruptedException e) { e.printStackTrace(); } } System.out.println(this.getName() + "...bb"); } } }; t1.start(); t2.start(); } }