/** * 使用BlockingQueue实现主子线程互相打印 * @author duwenlei * */ public class BlockingQueueTest { public static void main(String[] args) { final Business business = new Business(); new Thread(new Runnable() { @Override public void run() { while(true){ busines…
package com.thread.test.thread; import java.util.Random; import java.util.concurrent.*; /** * Created by windwant on 2016/5/26. */ public class MyBlockingQueue { public static void main(String[] args) throws InterruptedException { testArrayBlockingQu…
我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3555111.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验. [实现1:synchronized] 含测试函数main. public class ProductManagerUsingSync { static final int MAX_AMOUNT = 1000; int currentAmount; /** * @param args */ pub…