Package java.util.concurrent

Examples of java.util.concurrent.CyclicBarrier.await()


        final CyclicBarrier barrier=new CyclicBarrier(2);

        Thread thread=new Thread() {
            public void run() {
                try {
                    barrier.await();
                    Util.sleep(1000);
                    replenishAll(100);
                }
                catch(Exception e) {
                    e.printStackTrace();
View Full Code Here


        addAll();
        boolean rc=map.decrement(800, 100);
        assert rc;
        System.out.println("map:\n" + map);

        barrier.await();
        rc=map.decrement(250, 5000);
        assert rc;
        System.out.println("map:\n" + map);
        assert map.getMinCredits() == 50;
        assert map.getAccumulatedCredits() == 250;
View Full Code Here

            try
            {
               sem.acquire(); // we're first to the semaphore

               // log("waiting on barrier");
               barrier.await(); // wait until t2 joins us
               // log("passed barrier");
               lock = s.readLock();
               lock.tryLock(TIMEOUT, TimeUnit.MILLISECONDS);
               log("1st read: value is " + value);
               assertEquals(10, value);
View Full Code Here

         public void run()
         {
            try
            {
               TestingUtil.sleepThread(100);
               barrier.await();
               sem.acquire();
               lock = s.writeLock();
               lock.tryLock(TIMEOUT, TimeUnit.MILLISECONDS);
               log("changing value from " + value + " to 20");
               value = 20;
View Full Code Here

        CyclicBarrier barrier=new CyclicBarrier(3);

        Closer one=new Closer(c1, barrier), two=new Closer(c2, barrier);
        one.start(); two.start();
        Util.sleep(500);
        barrier.await(); // starts the closing of the 2 channels
        one.join(10000);
        two.join(10000);
        assertFalse(one.isAlive());
        assertFalse(two.isAlive());
    }
View Full Code Here

        for(int i=0; i < prios.length; i++) {
            senders[i]=new PrioSender(c1, prios[i], barrier);
            senders[i].start();
        }
        Util.sleep(500);
        barrier.await(); // starts the senders

        for(PrioSender sender: senders)
            sender.join();

        List<Integer> list1=r1.getMsgs(), list2=r2.getMsgs();
View Full Code Here

    assertEquals("Icon not equal to wait icon while loading", waitIconContent.getURL(), icon);

    // Let iconManager load the iconContent
    iconLoadingStartBarrier.await();
    // Wait iconContent loading completion
    waitingComponentBarrier.await();
    if (goodIcon) {
      assertEquals("Icon not equal to icon read from resource", iconURL, icon);
    } else {
      assertEquals("Wrong icon not equal to errorIcon", errorIconContent.getURL(), icon);
    }
View Full Code Here

                                    // should write the .sspace to disk.  In
                                    // addition, enqueue the time for this
                                    // document so the serialization thread can
                                    // reset the correct s-sspace start time
                                    futureStartTimes.offer(docTime);
                                    exceededTimeSpanBarrier.await();
                                } catch (InterruptedException ex) {
                                    return;
                                } catch (BrokenBarrierException ex) {
                                    return;
                                }
View Full Code Here

              WriteOrderOracle.next(), eventIn);
            ByteBuffer bytes = TransactionEventRecord.toByteBuffer(put);
            writer.put(bytes);
            writer.commit(TransactionEventRecord.toByteBuffer(
              new Commit(txnId.get(), WriteOrderOracle.next())));
            barrier.await();
            writer.sync();
          } catch (Exception ex) {
            Throwables.propagate(ex);
          }
          return null;
View Full Code Here

            senders[i].setName("sender-" + i);
            senders[i].start();
        }
        try {
            System.out.println("-- sending " + num_msgs + " msgs");
            barrier.await();
        }
        catch(Exception e) {
            System.err.println("failed triggering send threads: " + e);
        }
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.