线程中Join的使用例子

1.实现Runnbale接口,

package 网易若干java;
//这个例子共有2个线程,一个是主线程,一个是线程t public class MyThread1 implements Runnable{ public static void main(String args[]) throws InterruptedException
{
Thread t=new Thread(new MyThread1());
t.start();
System.out.println("rm1");
t.join(); //主线程等待线程t结束
System.out.println("rm2"); } @Override
public void run() {
// TODO Auto-generated method stub
System.out.println("r1");
System.out.println("r2"); } }

 

上一篇:element upload 上传报错 Uncaught TypeError: Cannot set property 'status' of undefined


下一篇:Spring - Spring容器概念及其初始化过程