高并发
zaoanmiao
得搞。。这个得搞。。
展开
-
高并发里的Exchanger交换机测试
@Test public void test04(){ Exchanger<String> exchanger = new Exchanger<>(); //new出交换机 new Thread(new Spy01(exchanger)).start(); //从构造方法传入对象中 new Thread(ne...原创 2018-12-04 11:56:13 · 265 阅读 · 0 评论 -
闭锁CountDownLatch
@Test public void test02() throws InterruptedException{ CountDownLatch cdl = new CountDownLatch(2); //new出CountDownLatch对象,初始指定线程数为2 new Thread(new BuyPot(cdl)).run(); ...原创 2018-12-04 12:02:43 · 185 阅读 · 0 评论 -
栅栏CyclicBarrier
@Test public void test03() throws Exception{ CyclicBarrier cb = new CyclicBarrier(2); //new栅栏,并作为构造方法传入 new Thread(new Horse1(cb)).start(); new Thread(new Horse2(cb))...原创 2018-12-05 09:18:45 · 155 阅读 · 0 评论