Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.Lock.newCondition()


    }

    @Test(timeout = 1500l)
    public void testConditionWaitsForSignalOtherClient() throws Exception{
        final Lock firstLock = new ReentrantZkLock(baseLockPath, zkSessionManager);
        final Condition firstCondition = firstLock.newCondition();

        firstLock.lock();
        //fire off a thread that will signal the main process thread
        Future<Void> errorFuture = testService.submit(new Callable<Void>() {
            @Override
View Full Code Here


            public Void call() throws Exception {
                final Lock otherClientLock;
                ZooKeeper newZk = newZooKeeper();
                try {
                    otherClientLock = new ReentrantZkLock(baseLockPath, new BaseZkSessionManager(newZk));
                    final Condition otherClientCondition = otherClientLock.newCondition();
                    otherClientLock.lock();
                    System.out.println("Lock acquired on second thread");
                    try {
                        otherClientCondition.signal();
                        System.out.println("Lock signalled on second thread");
View Full Code Here

    }

    @Test(timeout = 1000l)
    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.