Package java.util.concurrent.locks

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


    @Test
    public void testWithGlobalLocking() {
        ReentrantReadWriteLock readWriteLock = dhns.getReadWriteLock();
        Lock lock = readWriteLock.readLock();

        lock.lock();
        for (int i = 0; i < 100000; i++) {
            lock.lock();
            int degree = singleNode.getEdgesInTree().getCount() + singleNode.getEdgesOutTree().getCount();
            lock.unlock();
        }
View Full Code Here


        ReentrantReadWriteLock readWriteLock = dhns.getReadWriteLock();
        Lock lock = readWriteLock.readLock();

        lock.lock();
        for (int i = 0; i < 100000; i++) {
            lock.lock();
            int degree = singleNode.getEdgesInTree().getCount() + singleNode.getEdgesOutTree().getCount();
            lock.unlock();
        }
        lock.unlock();
    }
View Full Code Here

    if (i == batchSize) {
      sinkCounter.incrementBatchCompleteCount();
    }
    sinkCounter.addToEventDrainAttemptCount(i);

    lock.lock();
    try {
      while ((callbacksReceived.get() < callbacksExpected.get())
              && !txnFail.get()) {
        try {
          if(!condition.await(timeout, TimeUnit.MILLISECONDS)){
View Full Code Here

        String personId = validateWriteRequest(userId, groupId, appId, token);

        //lock on this user and this application to avoid any potential concurrency issues
        Lock lock = getApplicationDataLock(personId, appId);
        try {
            lock.lock();

            //get the application data for this user and application
            ApplicationData applicationData = applicationDataRepository.getApplicationData(personId, appId);

            //if there is no data, there's nothing to delete, so we're done...
View Full Code Here

        String personId = validateWriteRequest(userId, groupId, appId, token);

        //lock on this user and this application to avoid any potential concurrency issues
        Lock lock = getApplicationDataLock(personId, appId);
        try {
            lock.lock();
            //get the application data for this user and application
            ApplicationData applicationData = applicationDataRepository.getApplicationData(personId, appId);

            //if there is no data, create an empty object to store the data in that we'll save when we're done
            if (applicationData == null) {
View Full Code Here

            for (int i=0; i<3; i++) {
                if (i > 0)
                    Thread.sleep(333); // don't go too fast

                try {
                    lck.lock();
                    cnd.signalAll(); // this is the spurious wakeup
                } finally {
                    lck.unlock();
                }
View Full Code Here

        Thread.sleep(500); // just for fun, let it wait for some time
        // this may fail due to a spurious wakeup
        assertTrue("thread not waiting, spurious wakeup?", ath.isWaiting());

        try {
            lck.lock();
            wt.wakeup();
        } finally {
            lck.unlock();
        }
        ath.join(10000);
View Full Code Here

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

        try {
            lck.lock();
            wt.wakeup();
            fail("missing waiter not detected");
        } catch (IllegalStateException isx) {
            // expected
        } finally {
View Full Code Here

    @Override
    public void setResources(WebResourceRoot resources) {

        Lock writeLock = resourcesLock.writeLock();
        writeLock.lock();
        WebResourceRoot oldResources = null;
        try {
            if (getState().isAvailable()) {
                throw new IllegalStateException
                    (sm.getString("standardContext.resources.started"));
View Full Code Here

    public boolean resourcesStop() {

        boolean ok = true;

        Lock writeLock = resourcesLock.writeLock();
        writeLock.lock();
        try {
            if (resources != null) {
                resources.stop();
            }
        } catch (Throwable t) {
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.