Package com.hazelcast.core

Examples of com.hazelcast.core.ILock.lock()


    @Test(timeout = 60000)
    public void testForceUnlock_whenAcquiredMultipleTimesByCurrentThread() {
        HazelcastInstance instance = createHazelcastInstance();
        ILock lock = instance.getLock(randomString());
        lock.lock();
        lock.lock();

        lock.forceUnlock();

        assertFalse(lock.isLocked());
        assertEquals(0, lock.getLockCount());
View Full Code Here


        createThreadWaitsForCondition(latch, lock, condition0, syncLatch).start();
        createThreadWaitsForCondition(latch, lock, condition1, syncLatch).start();

        syncLatch.await();

        lock.lock();
        condition0.signal();
        lock.unlock();

        lock.lock();
        condition1.signal();
View Full Code Here

        lock.lock();
        condition0.signal();
        lock.unlock();

        lock.lock();
        condition1.signal();
        lock.unlock();

        assertOpenEventually(latch);
    }
View Full Code Here

        createThreadWaitsForCondition(latch, lock, condition, syncLatch).start();
        createThreadWaitsForCondition(latch, lock, condition, syncLatch).start();

        syncLatch.await();

        lock.lock();
        condition.signalAll();
        lock.unlock();

        assertOpenEventually(latch);
    }
View Full Code Here

        createThreadWaitsForCondition(latch, lock, condition0, syncLatch).start();
        createThreadWaitsForCondition(latch, lock, condition1, syncLatch).start();

        syncLatch.await();

        lock.lock();
        condition0.signalAll();
        lock.unlock();

        assertTrueDelayed5sec(new AssertTask() {
            @Override
View Full Code Here

        createThreadWaitsForCondition(latch, lock, condition0, syncLatch).start();
        createThreadWaitsForCondition(latch, lock, condition1, syncLatch).start();

        syncLatch.await();

        lock.lock();
        condition0.signalAll();
        lock.unlock();

        assertOpenEventually(latch);
    }
View Full Code Here

    public void testAwaitTime_whenTimeout() throws InterruptedException {
       HazelcastInstance instance = createHazelcastInstance();

        final ILock lock = instance.getLock(randomString());
        final ICondition condition = lock.newCondition(randomString());
        lock.lock();

        boolean success = condition.await(1, TimeUnit.MILLISECONDS);

        assertFalse(success);
        assertTrue(lock.isLockedByCurrentThread());
View Full Code Here

        lock0.lock();
        condition0.signalAll();
        lock0.unlock();

        lock1.lock();
        condition1.signalAll();
        lock1.unlock();

        assertOpenEventually(latch);
    }
View Full Code Here

        final AtomicInteger count = new AtomicInteger(0);

        Thread t = new Thread(new Runnable() {
            public void run() {
                try {
                    lock.lock();
                    if (lock.isLockedByCurrentThread()) {
                        count.incrementAndGet();
                    }
                    condition.await();
                    if (lock.isLockedByCurrentThread()) {
View Full Code Here

        });
        t.start();
        Thread.sleep(1000);

        assertEquals(false, lock.isLocked());
        lock.lock();
        assertEquals(true, lock.isLocked());
        condition.signal();
        lock.unlock();
        t.join();
        assertEquals(2, count.get());
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.