Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.Condition.await()


        int max_tries=30;
        lock.lock();
        try {
            while(delivered_msgs.get() < num_msgs && max_tries-- > 0) {
                try {
                    all_msgs_delivered.await(1000, TimeUnit.MILLISECONDS);
                    System.out.println("received " + delivered_msgs.get() + " msgs");
                }
                catch(InterruptedException e) {
                    e.printStackTrace();
                }
View Full Code Here


        public void run() {
            if (tryLock(lock, LOCK)) {
               try {
                  Condition condition = lock.newCondition();
                  try {
                     condition.await();
                  } catch (InterruptedException e) {
                     System.out.println("");
                  }
               }
               finally {
View Full Code Here

      {
        Condition localCondition = paramGuard.condition;
        do
          try
          {
            localCondition.await();
          }
          catch (InterruptedException localInterruptedException)
          {
            try
            {
View Full Code Here

       
        workqueue.schedule(doNothing, 5000);
       
        runLock.lock();
        try {
            runCondition.await();
        } finally {
            runLock.unlock();
        }
       
        assertTrue("expected delay",
View Full Code Here

                    final Buffer buffer;
                    lock.lock();
                    try {
                        while (size >= buffers2Length) {
                            try {
                                signal.await();
                            } catch (InterruptedException cancel) {
                                return;
                            }
                        }
                        buffer = buffers2[(off + size) % buffers2Length];
View Full Code Here

                final Buffer buffer;
                lock.lock();
                try {
                    while (0 >= reader.size) {
                        try {
                            signal.await();
                        } catch (InterruptedException interrupt) {
                            interrupted = true;
                        }
                    }
                    off = reader.off;
View Full Code Here

            }
        });

        //wait for signal notification
        System.out.println("First thread waiting for notification");
        firstCondition.await();
        System.out.println("First thread has been notified");
    }

    @Test(timeout = 1500l)
    @Ignore("Ignored until Conditions are fully implemented in ReentrantZkLock2")
View Full Code Here

    public void testConditionTimesOut() throws Exception{
        Lock firstLock = new ReentrantZkLock2(baseLockPath,zkSessionManager);
        Condition firstCondition = firstLock.newCondition();

        firstLock.lock();
        boolean timedOut = firstCondition.await(250l, TimeUnit.MILLISECONDS);
        assertTrue("Condition did not time out!",!timedOut);
        firstLock.unlock();
    }

View Full Code Here

            }
        });

        //wait for signal notification
        System.out.println("First thread waiting for notification");
        firstCondition.await();
        System.out.println("First thread has been notified");
    }

    @Test(timeout = 1500l)
    public void testConditionWaitsForSignalOtherClient() throws Exception{
View Full Code Here

    public void testConditionTimesOut() throws Exception{
        Lock firstLock = new ReentrantZkLock(baseLockPath,zkSessionManager);
        Condition firstCondition = firstLock.newCondition();

        firstLock.lock();
        boolean timedOut = firstCondition.await(250l, TimeUnit.MILLISECONDS);
        assertTrue("Condition did not time out!",!timedOut);
        firstLock.unlock();
    }

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.