Examples of acquire()


Examples of java.util.concurrent.Semaphore.acquire()

         MessageDispatcher disp = dispatchers[i % 2];
           
         runners[i] = new ClassLoaderLeakRunner(disp, numLoops, runnerGroup, semaphore);        
      }

      semaphore.acquire(numThreads);
     
      for (int i = 0; i < runners.length; i++)
      {
         runners[i].start();
      }
View Full Code Here

Examples of java.util.concurrent.Semaphore.acquire()

            // going through the peer list and starting a new publisher thread for each peer
            int i = 0;
            while (si.hasNext()) {
                seed = si.next();
                if (seed == null) {
                    sync.acquire();
                    continue;
                }
                i++;

                final String address = seed.getClusterAddress();
View Full Code Here

Examples of java.util.concurrent.Semaphore.acquire()

                if (log.isFine()) log.logFine("HELLO #" + i + " to peer '" + seed.get(yacySeed.NAME, "") + "' at " + address); // debug
                final String seederror = seed.isProper(false);
                if ((address == null) || (seederror != null)) {
                    // we don't like that address, delete it
                    sb.peers.peerActions.peerDeparture(seed, "peer ping to peer resulted in address = " + address + "; seederror = " + seederror);
                    sync.acquire();
                } else {
                    // starting a new publisher thread
                    contactedSeedCount++;
                    (new publishThread(yacyCore.publishThreadGroup, seed, sync, syncList)).start();
                }
View Full Code Here

Examples of java.util.concurrent.Semaphore.acquire()

            // receiving the result of all started publisher threads
            for (int j = 0; j < contactedSeedCount; j++) {

                // waiting for the next thread to finish
                sync.acquire();

                // if this is true something is wrong ...
                if (syncList.isEmpty()) {
                    log.logWarning("PeerPing: syncList.isEmpty()==true");
                    continue;
View Full Code Here

Examples of java.util.concurrent.Semaphore.acquire()

      Assert.assertEquals(100L, startScnCp.getBootstrapStartScn().longValue());

      log.info("instrument the client pipeline so that we can intercept and delay the channelClosed message");
      final Semaphore passMessage = new Semaphore(1);
      final CountDownLatch closeSent = new CountDownLatch(1);
      passMessage.acquire();
      conn._channel.getPipeline().addBefore("handler", "closeChannelDelay",
          new SimpleChannelHandler(){
            @Override
            public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
              closeSent.countDown();
View Full Code Here

Examples of java.util.concurrent.Semaphore.acquire()

      conn._channel.getPipeline().addBefore("handler", "closeChannelDelay",
          new SimpleChannelHandler(){
            @Override
            public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
              closeSent.countDown();
              passMessage.acquire();
              try
              {
                super.channelClosed(ctx, e);
              }
              finally
View Full Code Here

Examples of java.util.concurrent.Semaphore.acquire()

            if (loadingGuards.get(key) == null) {
                loadingGuards.putIfAbsent(key, new Semaphore(1));
            }
            final Semaphore loadingGuard = loadingGuards.get(key);
            try {
                loadingGuard.acquire();
                resourceBundle = resourceBundleCache.get(key);
                if (resourceBundle != null) {
                    log.debug("getResourceBundleInternal({}): got cache hit on second try", key);
                } else {
                    log.debug("getResourceBundleInternal({}): reading from Repository", key);
View Full Code Here

Examples of java.util.concurrent.Semaphore.acquire()

                         comparisons, sspace, vector,
                         other, similarityType, mostSimilar));
        }
       
        try {
            comparisons.acquire();
        } catch (InterruptedException ie) {
            // check whether we were interrupted while still waiting for the
            // comparisons to finish
             if (comparisons.availablePermits() < 1) {
                throw new IllegalStateException(
View Full Code Here

Examples of java.util.concurrent.Semaphore.acquire()

                });
        }
       
        // Wait until all the documents have been processed
        try {
            termsProcessed.acquire(uniqueTerms);
        } catch (InterruptedException ie) {
            throw new Error("interrupted while waiting for terms to " +
                            "finish reprocessing", ie);
        }       
        LOGGER.info("finished reprocessing all terms");
View Full Code Here

Examples of java.util.concurrent.Semaphore.acquire()

            });
        }
               
        // Wait
        try {
            itemsProcessed.acquire(numQuestions);
        } catch (InterruptedException ie) {
            throw new Error(ie);
        }

        // Copy over the answered questions to a smaller array so that
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.