Package java.util.concurrent.locks

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



    public void testIllegal() throws InterruptedException {

        Lock      lck = new ReentrantLock();
        Condition cnd = lck.newCondition();
        WaitingThread wt = new WaitingThread(cnd, null);

        try {
            lck.lock();
            wt.wakeup();
View Full Code Here


        workqueue = new AutomaticWorkQueueImpl(UNBOUNDED_MAX_QUEUE_SIZE, INITIAL_SIZE,
                                               UNBOUNDED_HIGH_WATER_MARK,
                                               UNBOUNDED_LOW_WATER_MARK,
                                               DEFAULT_DEQUEUE_TIMEOUT);
        final Lock runLock = new ReentrantLock();
        final Condition runCondition = runLock.newCondition();
        long start = System.currentTimeMillis();
        Runnable doNothing = new Runnable() {
            public void run() {
                runLock.lock();
                try {
View Full Code Here

    }
    AtomicBoolean txnFail = new AtomicBoolean(false);
    AtomicInteger callbacksReceived = new AtomicInteger(0);
    AtomicInteger callbacksExpected = new AtomicInteger(0);
    final Lock lock = new ReentrantLock();
    final Condition condition = lock.newCondition();
    if (incrementBuffer != null) {
      incrementBuffer.clear();
    }
    /*
     * Callbacks can be reused per transaction, since they share the same
View Full Code Here

        workqueue = new AutomaticWorkQueueImpl(UNBOUNDED_MAX_QUEUE_SIZE, INITIAL_SIZE,
                                               UNBOUNDED_HIGH_WATER_MARK,
                                               UNBOUNDED_LOW_WATER_MARK,
                                               DEFAULT_DEQUEUE_TIMEOUT);
        final Lock runLock = new ReentrantLock();
        final Condition runCondition = runLock.newCondition();
        long start = System.currentTimeMillis();
        Runnable doNothing = new Runnable() {
            public void run() {
                runLock.lock();
                try {
View Full Code Here

          }
        }
      });

      Lock startLock = new ReentrantLock();
      Condition startCondition = startLock.newCondition();
      MetaStoreThread.BooleanPointer startedServing = new MetaStoreThread.BooleanPointer();
      startMetaStoreThreads(conf, startLock, startCondition, startedServing);
      startMetaStore(cli.port, ShimLoader.getHadoopThriftAuthBridge(), conf, startLock,
          startCondition, startedServing);
    } catch (Throwable t) {
View Full Code Here

        Lock lock2=s2.getLock(LOCK);
        Thread locker=new Signaller(true);
        boolean rc=tryLock(lock2, 5000, LOCK);
        assert rc;
        locker.start();
        assert awaitNanos(lock2.newCondition(), TimeUnit.SECONDS.toNanos(5), LOCK) > 0 : "Condition was not signalled";
        unlock(lock2, LOCK);
    }


    public void testSuccessfulTryLockTimeout() throws InterruptedException, BrokenBarrierException {
View Full Code Here

        lock.lock();
        lock.unlock();
        lock.lockInterruptibly();

        assertNull(lock.newCondition());
        assertTrue(lock.tryLock());
        assertTrue(lock.tryLock(0, null));
    }
}
View Full Code Here

        workqueue = new AutomaticWorkQueueImpl(UNBOUNDED_MAX_QUEUE_SIZE, INITIAL_SIZE,
                                               UNBOUNDED_HIGH_WATER_MARK,
                                               UNBOUNDED_LOW_WATER_MARK,
                                               DEFAULT_DEQUEUE_TIMEOUT);
        final Lock runLock = new ReentrantLock();
        final Condition runCondition = runLock.newCondition();
        long start = System.currentTimeMillis();
        Runnable doNothing = new Runnable() {
            public void run() {
                runLock.lock();
                try {
View Full Code Here

  public static void main(String[] args) {
    //final Object sharedLock = new Object();
    //ProcessBus processBus = new ProcessBus();
    Lock lock = new ReentrantLock();
    Condition condition = lock.newCondition();

    new Thread(new WorkerProcessB(lock, condition)).start();
    new Thread(new WorkerProcessA(lock, condition)).start();

    // should slowly (300ms a letter) print:
View Full Code Here

        } catch (IllegalArgumentException iax) {
            // expected
        }

        Lock      lck = new ReentrantLock();
        Condition cnd = lck.newCondition();

        WaitingThread wt = new WaitingThread(cnd, null);
        assertEquals("wrong condition", cnd, wt.getCondition());
        assertNull  ("pool from nowhere", wt.getPool());
        assertNull  ("thread from nowhere", wt.getThread());
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.