Package java.util.concurrent

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


            // 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

      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

      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

            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

                         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

                });
        }
       
        // 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

            });
        }
               
        // 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

        }
        corpusReader.close();

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

               if (executorService != null)
               {
                  try
                  {
                     taskSepaphore.acquire();
                     executorService.execute(task);
                  }
                  catch (RejectedExecutionException e)
                  {
                     // this may happen because of a race condition between the
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.