摘要: public class ProducterConsumerSample { public static void main(String[] args) { Resourse res = new Resourse(); //两个生产者 Producter producter1 = new Producter(res); Producter producter2 = new Producter(r 阅读全文
posted @ 2019-09-29 16:07 深南大道 阅读(966) 评论(0) 推荐(0)
摘要: public class ThreadNotifySample { public static void main(String[] args) { // Res res = new Res(); // Input input = new Input(res); // Output output = new Output(res); // Thread t1 = new Thread(input) 阅读全文
posted @ 2019-09-29 15:03 深南大道 阅读(315) 评论(0) 推荐(0)
摘要: public class DeadLockSample { public static void main(String[] args) { DeadLock d1 = new DeadLock(true); DeadLock d2 = new DeadLock(false); d1.start(); d2.start(); } } class Lock { /** * 死锁定义 所谓死锁是指两个 阅读全文
posted @ 2019-09-29 13:52 深南大道 阅读(233) 评论(0) 推荐(0)
摘要: public class InstanceSampleTest { public static void main(String[] args) { /** 单例设计模式的 饿汉式和懒汉式 * 单例模式,我们首先必须将类在一个虚拟机中只能产生一个对象,因此应该做到以下几步: * a:私有化构造方法,这样在该类的外边就不能用new操作来创建对象,但是在类的内部可以创建该类的对象。 * b:调用该类的 阅读全文
posted @ 2019-09-29 12:41 深南大道 阅读(301) 评论(0) 推荐(0)