Package java.util.concurrent.locks

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


            errorFuture = testService.submit(new Callable<Void>() {
                @Override
                public Void call() throws Exception {
                    Lock secondLock = new ReentrantZkLock2(baseLockPath, zkSessionManager);
                    logger.debug("interruptible acquiring lock");
                    secondLock.lockInterruptibly();
                    logger.debug("acquired");
                    try {
                        latch.countDown();
                    } finally {
                        secondLock.unlock();
View Full Code Here


    @Test(timeout = 1000l)
    public void testLockInterruptiblyWorksSameInstance() throws Exception{
        final CountDownLatch latch = new CountDownLatch(1);
        final Lock firstLock = new ReentrantZkLock2(baseLockPath, zkSessionManager);
        firstLock.lockInterruptibly();
        Future<Void>errorFuture;
        try{
            errorFuture = testService.submit(new Callable<Void>() {
                @Override
                public Void call() throws Exception {
View Full Code Here

        try{
            errorFuture = testService.submit(new Callable<Void>() {
                @Override
                public Void call() throws Exception {
//                    Lock secondLock = new ReentrantZkLock(baseLockPath, commandExecutor);
                    firstLock.lockInterruptibly();
                    try {
                        latch.countDown();
                    } finally {
                        firstLock.unlock();
                    }
View Full Code Here

                    Lock secondaryLock = new ReentrantZkLock2(baseLockPath, zkSessionManager);
                    boolean thrown = false;
                    try {
                        System.out.printf("%s: Attempting to acquire the lock interruptibly%n",Thread.currentThread().getName());
                        latch.await();
                        secondaryLock.lockInterruptibly();
                        fail("secondary Lock was acquired improperly!");
                    } catch (InterruptedException ie) {
                        System.out.printf("%s: Secondary lock threw an InterruptedException$n",Thread.currentThread().getName());
                        thrown = true;
                    } catch (BrokenBarrierException e) {
View Full Code Here

                    Lock secondaryLock = new ReentrantZkLock2(baseLockPath, zkSessionManager);
                    boolean thrown = false;
                    try {
                        System.out.printf("%s: Attempting to acquire the lock interruptibly%n",Thread.currentThread().getName());
                        latch.await();
                        secondaryLock.lockInterruptibly();
                        fail("secondary Lock was acquired improperly!");
                    } catch (InterruptedException ie) {
                        System.out.printf("%s: Secondary lock threw an InterruptedException$n",Thread.currentThread().getName());
                        thrown = true;
                    } catch (BrokenBarrierException e) {
View Full Code Here

    }

    @Test(timeout = 1000l)
    public void testLockInterruptiblyReentrant() throws Exception{
        Lock lock = new ReentrantZkLock2(baseLockPath,zkSessionManager);
        lock.lockInterruptibly();
        try{
            //try to enter the lock again
            lock.lockInterruptibly();
            //success! we're gravy
            lock.unlock();
View Full Code Here

    public void testLockInterruptiblyReentrant() throws Exception{
        Lock lock = new ReentrantZkLock2(baseLockPath,zkSessionManager);
        lock.lockInterruptibly();
        try{
            //try to enter the lock again
            lock.lockInterruptibly();
            //success! we're gravy
            lock.unlock();
        }finally{
            lock.unlock();
        }
View Full Code Here

        readLock.lock();
        Future<Void> writeFuture = testService.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                Lock writeLock = rwLock.writeLock();
                writeLock.lockInterruptibly();
                try{
                    return null;
                }finally {
                    writeLock.unlock();
                }
View Full Code Here

        If this mechanism is broken, then this test will fail
        */
        final ReentrantZkReadWriteLock2 rwLock = new ReentrantZkReadWriteLock2(baseLockPath, zkSessionManager);
        Lock readLock = rwLock.readLock();

        readLock.lockInterruptibly();
        Future<Void> writeFuture = testService.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                Lock writeLock = rwLock.writeLock();
                writeLock.lockInterruptibly();
View Full Code Here

        readLock.lockInterruptibly();
        Future<Void> writeFuture = testService.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                Lock writeLock = rwLock.writeLock();
                writeLock.lockInterruptibly();
                try{
                    return null;
                }finally {
                    writeLock.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.