BlockingQueue与InterruptedException
感谢Blader同学的抛砖首先,这段代码会编译成功吗,运行起来会有异常吗,他会打印什么?import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue;public class Foo { public static void main(String[] [more...]
感谢Blader同学的抛砖首先,这段代码会编译成功吗,运行起来会有异常吗,他会打印什么?import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue;public class Foo { public static void main(String[] [more...]
引子: 大家上过操作系统的都知道“生产者-消费者(Producer-Consumer)”模型,主要讨论的是进程(线程)间的互斥和同步问题,关键是对锁(lock)的申请、独占和释放,在这里我就不罗嗦了。原先我写的Java代码如下: public class Producer extends Thread{ private ProductList products = [more...]