Package java.util.concurrent.locks

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


                return true;
            } else {
                int h1 = hash1(x);
                Lock lock1 = locks[1][h1 % LOCKS];
                try {
                    lock1.lock();
                    if(x.equals(table[1][h1])) {
                        table[1][h1] = null;
                        return true;
                    }
                    return false;
View Full Code Here


    boolean validate(TreeSet<Intent>[] intentions, List<Lock> acquired) {
        for(int phase = 0; phase < 2; phase++) {
            for(Intent intent : intentions[phase]) {
                // lock and prepare to unlock
                Lock lock = locks[phase][intent.index % LOCKS];
                lock.lock();
                acquired.add(lock);
                // beware that expected could be null
                T expected = intent.item;
                T found = table[phase][intent.index];
                if(expected == null) {
View Full Code Here

    @Override
    public final void acquire(T x) {
        Lock lock0 = lock[0][hash0(x) % lock[0].length];
        Lock lock1 = lock[1][hash1(x) % lock[1].length];
        lock0.lock();
        lock1.lock();
    }

    /**
     * synchronize after adding, removing, or testing for item
     * @param x item involved
View Full Code Here

                    NakAckHeader hdr=(NakAckHeader)((Message)evt.getArg()).getHeader(NAKACK_ID);
                    if(hdr != null)
                        delivered_msg_list.add(hdr.getSeqno());

                    if(delivered_msgs.get() >= num_msgs) {
                        lock.lock();
                        try {
                            all_msgs_delivered.signalAll();
                        }
                        finally {
                            lock.unlock();
View Full Code Here

        }

        long start=System.currentTimeMillis();
        latch.countDown(); // starts all adders

        lock.lock();
        try {
            while(delivered_msgs.get() < num_msgs) {
                try {
                    all_msgs_delivered.await(1000, TimeUnit.MILLISECONDS);
                    System.out.println("received " + delivered_msgs.get() + " msgs");
View Full Code Here

    for (int index = 0; index < length; index++) {
      DirectoryProvider directoryProvider = directoryProviders[index];
      IndexReader reader;
      Lock directoryProviderLock = perDirectoryProviderManipulationLocks.get( directoryProvider );
      if ( trace ) log.trace( "Opening IndexReader from " + directoryProvider.getDirectory().toString() );
      directoryProviderLock.lock(); //needed for same problem as the double-checked locking
      try {
        reader = activeSearchIndexReaders.get( directoryProvider );
      }
      finally {
        directoryProviderLock.unlock();
View Full Code Here

          reader = replaceActiveReader( outOfDateReader, directoryProviderLock, directoryProvider, readers );
        }
        else {
          if ( trace )
            log.trace( "Valid shared IndexReader: " + directoryProvider.getDirectory().toString() );
          directoryProviderLock.lock();
          try {
            //read the latest active one, the current one could be out of date and closed already
            //the latest active is guaranteed to be active because it's protected by the dp lock
            reader = activeSearchIndexReaders.get( directoryProvider );
            semaphoreIndexReaderLock.lock();
View Full Code Here

      }

      //acquire the locks in the same order as everywhere else
      Lock directoryProviderLock = perDirectoryProviderManipulationLocks.get( readerData.provider );
      boolean closeReader = false;
      directoryProviderLock.lock();
      try {
        boolean isActive;
        isActive = activeSearchIndexReaders.get( readerData.provider ) == subReader;
        if ( trace ) log.trace( "Indexreader not active: " + subReader );
        semaphoreIndexReaderLock.lock();
View Full Code Here

    }

    public static class NoCleanUpRemoteProcess implements Action<WorkerProcessContext>, Serializable {
        public void execute(WorkerProcessContext workerProcessContext) {
            final Lock lock = new ReentrantLock();
            lock.lock();
            new Thread(new Runnable() {
                public void run() {
                    lock.lock();
                }
            }).start();
View Full Code Here

        public void execute(WorkerProcessContext workerProcessContext) {
            final Lock lock = new ReentrantLock();
            lock.lock();
            new Thread(new Runnable() {
                public void run() {
                    lock.lock();
                }
            }).start();

            TestListenerInterface sender = workerProcessContext.getServerConnection().addOutgoing(
                    TestListenerInterface.class);
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.