Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.ReentrantReadWriteLock


   */
  public ResizablePersistentIntBuffer(File f, int size) throws IOException {
    this.filename = f;
    isNew = !f.exists();
    this.raf = new RandomAccessFile(f, "rw");
    this.lock = new ReentrantReadWriteLock();
    this.size = size;
    buffer = new int[size];
    long expectedLength = ((long)size)*4;
    long realLength = raf.length();
    if(realLength > expectedLength)
View Full Code Here


  protected final int length;

  protected transient ReadWriteLock lock = new ReentrantReadWriteLock();
 
  public void init() {
    lock = new ReentrantReadWriteLock();
  }
View Full Code Here

     *              will be towards newer values
     * @param clock the clock used to timestamp samples and track rescaling
     */
    public ExponentiallyDecayingReservoir(int size, double alpha, Clock clock) {
        this.values = new ConcurrentSkipListMap<Double, WeightedSample>();
        this.lock = new ReentrantReadWriteLock();
        this.alpha = alpha;
        this.size = size;
        this.clock = clock;
        this.count = new AtomicLong(0);
        this.startTime = currentTimeInSeconds();
View Full Code Here

    for(int i = 0; i < NUM_TESTS; i++){
     
      new Thread(new Runnable(){
       
       
        private final ReadWriteLock rwl = new ReentrantReadWriteLock();

        @Override
        public void run() {
          Random rand= new Random();
          int min = 700, max = 10000;
          int randomNum = rand.nextInt(max - min + 1) + min;
        // try and throw threads of sequential access 
           try {
            Thread.sleep(randomNum);
          } catch (InterruptedException e) {
            e.printStackTrace();
          }
         
          Lock rl = rwl.writeLock();
          rl.lock();
          atom.incrementAndGet();
          rl.unlock();
         
          Lock wl = rwl.readLock();
          wl.lock();
          System.out.println("threadId "+threadId +"lockOblect state "+atom.get());
         
          wl.unlock();
          threadId++;
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public ReadWriteLock getRWLock()
    {
        return new ReentrantReadWriteLock();
    }
View Full Code Here

    this.user = user;
    this.appId = appId;
    this.credentials = credentials;
    this.aclsManager = context.getApplicationACLsManager();
    this.context = context;
    ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
    readLock = lock.readLock();
    writeLock = lock.writeLock();
    stateMachine = stateMachineFactory.make(this);
  }
View Full Code Here

    this.committer = committer;
    this.newApiCommitter = newApiCommitter;

    this.taskAttemptListener = taskAttemptListener;
    this.eventHandler = eventHandler;
    ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
    this.readLock = readWriteLock.readLock();
    this.writeLock = readWriteLock.writeLock();

    this.jobCredentials = jobCredentials;
    this.jobTokenSecretManager = jobTokenSecretManager;

    this.aclsManager = new JobACLsManager(conf);
View Full Code Here

    // Initialize reportedStatus
    reportedStatus = new TaskAttemptStatus();
    initTaskAttemptStatus(reportedStatus);

    ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
    readLock = readWriteLock.readLock();
    writeLock = readWriteLock.writeLock();

    this.credentials = credentials;
    this.jobToken = jobToken;
    this.eventHandler = eventHandler;
    this.jobFile = jobFile;
View Full Code Here

        else
        {
            if ( rwLock == null )
            {
                // Create a ReadWrite lock from scratch
                rwLock = new ReentrantReadWriteLock();
            }
        }
    }
View Full Code Here

        try
        {
            if( rwLock == null )
            {
                // Create a ReadWrite lock from scratch
                rwLock = new ReentrantReadWriteLock();
            }

            // load the last stored valid CSN value
            String contextEntryId = getEntryId( getSuffixDn() );
           
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.