Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.ReentrantReadWriteLock


        super(capacity);
        locks = new Lock[capacity];
        for(int j = 0; j < locks.length; j++) {
            locks[j] = new ReentrantLock();
        }
        ReadWriteLock rwLock = new ReentrantReadWriteLock();
        readLock = rwLock.readLock();
        writeLock = rwLock.writeLock();
    }
View Full Code Here


                + ", scanPercentage: " + percent + ", scanLength: " + scanLength + ", pageSize: "
                + pageSize);

        final Segments pager = makeTempSegments(pageSize);
        final Status[] stats = new Status[threads];
        final ReadWriteLock rwlock = new ReentrantReadWriteLock();

        final boolean isGCLOCK = (algo == ReplacementAlgorithm.GClock);

        _start = _stop = false;
        final Thread[] thrs = new Thread[threads];
View Full Code Here

                + ", scanPercentage: " + percent + ", scanLength: " + scanLength + ", pageSize: "
                + pageSize);

        final Segments pager = makeTempSegments(pageSize);
        final Status[] stats = new Status[threads];
        final ReadWriteLock rwlock = new ReentrantReadWriteLock();

        final boolean isGCLOCK = (algo == ReplacementAlgorithm.GClock);

        _start = _stop = false;
        final Thread[] thrs = new Thread[threads];
View Full Code Here

         throw ex;
   }

   public void testMoreWriteReleasesThanAcquisitions() throws InterruptedException
   {
      lock = new ReentrantReadWriteLock();
      lock.writeLock().lock();
      lock.writeLock().unlock();
      try
      {
         lock.writeLock().unlock();
View Full Code Here

      }
   }

   public void testMoreReadReleasesThanAcquisitions() throws InterruptedException
   {
      lock = new ReentrantReadWriteLock();
      lock.readLock().lock();
      lock.readLock().unlock();
      try
      {
         lock.readLock().unlock();
View Full Code Here

      }
   }

   public void testSimple() throws InterruptedException
   {
      lock = new ReentrantReadWriteLock();
      lock.readLock().lock();
      // upgrades must be manual; involving giving up the RL first.  Sucks.
      // see http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/locks/ReentrantReadWriteLock.html
      lock.readLock().unlock();
View Full Code Here

      lock.writeLock().lock();
   }

   public void testOneWriterMultipleReaders() throws InterruptedException
   {
      lock = new ReentrantReadWriteLock();

      Writer writer = new Writer("writer");
      Reader reader1 = new Reader("reader1");
      Reader reader2 = new Reader("reader2");
View Full Code Here

    private static ReadWriteLock accquireLock(final String key, final Map<String, ReadWriteLock> locks) {
        ReadWriteLock lock;
        synchronized(locks) {
            lock = locks.get(key);
            if(lock == null) {
                lock = new ReentrantReadWriteLock();
                locks.put(key, lock);
            }
        }
        lock.writeLock().lock();
        return lock;
View Full Code Here

            singletonPool.setPoolConfiguration(poolConfig);
            setPool(new PoolWrapper<EasyBeansSingletonSB>(singletonPool));
        }

        // pool
        this.lock = new ReentrantReadWriteLock();
    }
View Full Code Here

  private Map<Supplier, Object> supplierCache;
  private List<Blob> blobsToSave;
  private List<Blob> blobsToDelete;

  public ObjectDatabase(PersistenceEngine persistenceEngine) {
    this.lock = new ReentrantReadWriteLock();
    this.objectRepository = new ObjectRepository();
    this.supplierCache = new HashMap();
    this.persistenceEngine = persistenceEngine;
  }
View Full Code Here

TOP

Related Classes of java.util.concurrent.locks.ReentrantReadWriteLock

Copyright © 2018 www.massapicom. 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.