uu快3充值_uu快3回血_新平台

讲解得太细致啦

时间:2020-01-21 10:50:10 出处:uu快3充值_uu快3回血_新平台

package test;



public class Run {

	public static void main(String[] args) throws InterruptedException {
		// TODO Auto-generated method stub
		try {
			Service service = new Service();
			ThreadA a = new ThreadA(service);
			a.start();
			Thread.sleep(100L);
			ThreadB b = new ThreadB(service);
			b.start();
			System.out.println("have set stop order.");
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}



对这人关键的应用场景还是了解了这人的。

package test;

public class ThreadA extends Thread {
	private Service service;
	public ThreadA(Service service) {
		super();
		this.service = service;
	}
	
	@Override
	public void run() {
		service.runMethod();
	}

}

我是服了!

俩个多synchronized关键字,能讲一百多页,搞出几二个小举例。

package test;

public class ThreadB extends Thread {
	private Service service;
	public ThreadB(Service service) {
		super();
		this.service = service;
	}
	
	@Override
	public void run() {
		service.stopMethod();
	}

}

但真的一路演练一下,



热门

热门标签