Package java.util.concurrent

Examples of java.util.concurrent.ThreadPoolExecutor.awaitTermination()


            executorService.execute(new Sweeper(ids, exceptionQueue));
        }

        try {
            executorService.shutdown();
            executorService.awaitTermination(100, TimeUnit.MINUTES);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        count -= exceptionQueue.size();
View Full Code Here


    // Shutdown the pool
    threadPool.shutdown();

    // Wait for all the tasks to finish
    try {
      boolean stillRunning = !threadPool.awaitTermination(
          this.fileSplitTimeout, TimeUnit.MILLISECONDS);
      if (stillRunning) {
        threadPool.shutdownNow();
        // wait for the thread to shutdown completely.
        while (!threadPool.isTerminated()) {
View Full Code Here

      int threadWakeFrequency = conf.getInt(HConstants.THREAD_WAKE_FREQUENCY,
          60 * 1000);
      try {
        // here we wait until TPE terminates, which is either naturally or by
        // exceptions in the execution of the threads
        while (!tpe.awaitTermination(threadWakeFrequency,
            TimeUnit.MILLISECONDS)) {
          // printing out rough estimate, so as to not introduce
          // AtomicInteger
          LOG.info("Locality checking is underway: { Scanned Regions : "
              + tpe.getCompletedTaskCount() + "/"
View Full Code Here

        FutureTask<?> client = new FutureTask<Object>(clientImpl, null);
        ThreadPoolExecutor tpe = new ThreadPoolExecutor(1, 1, 10000L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>());
        tpe.execute(client);
        tpe.shutdown();
        tpe.awaitTermination(timeOut, timeUnit);
        if (!client.isDone()) {
            return false;
        }
        return true;
    }
View Full Code Here

              }
            }
          }
          try {
            tpe.shutdown();
            tpe.awaitTermination(20, TimeUnit.SECONDS);
          } catch (InterruptedException e) {
            LOGGER.error("error while shutting down thread pool executor for " + systemName, e);
          }

          LOGGER.trace("End of analysis for " + systemName);
View Full Code Here

       
        threadPool.execute(r);
      }

      threadPool.shutdown();
      threadPool.awaitTermination(Integer.MAX_VALUE, TimeUnit.DAYS);
      return matrix;
    } catch (InterruptedException e) {

      System.err.println("MatrixWorkerFactory : getMatrix impossible");
      e.printStackTrace();
View Full Code Here

      threadsList.add( searcherThread );
      threadPool.execute( searcherThread );
    }
    threadPool.shutdown();//required to enable awaitTermination functionality
    startSignal.countDown();//start all created threads
    boolean terminationOk = threadPool.awaitTermination( 60, TimeUnit.SECONDS );
    if ( terminationOk==false ) {
      System.out.println( "No enough time to complete the tests!" );
      return 0;
    }
    long totalTime = 0;
View Full Code Here

    for ( int i = 0; i < SEARCHES_NUM; i++ ) {
      executor.execute( makeTask( i ) );
    }
    executor.shutdown();
    startSignal.countDown();
    executor.awaitTermination( 500, TimeUnit.SECONDS );
    assertTrue( "memory leak: holding a reference to some unused IndexReader", readerProvider.areAllOldReferencesGone() );
    for ( MockIndexReader reader : readerProvider.getCreatedIndexReaders() ) {
      if ( readerProvider.isReaderCurrent( reader ) ) {
        assertTrue( "the most current reader should be open", ! reader.isClosed() );
      }
View Full Code Here

    ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool( WORKER_THREADS );
    for ( int batch = 0; batch <= INDEX_ELEMENTS; batch++ ) {
      executor.execute( filler );
    }
    executor.shutdown();
    executor.awaitTermination( 600, TimeUnit.SECONDS );
    iw.commit();
    iw.forceMergeDeletes();
    iw.forceMerge( 1 );
    iw.close();
    System.out.println( "Index created." );
View Full Code Here

      }
    }
    executor.shutdown();
    long startTime = System.nanoTime();
    startSignal.countDown();//start!
    executor.awaitTermination( 600, TimeUnit.SECONDS );
    long endTime = System.nanoTime();
    System.out.println(
        "Performance test for " + getReaderStrategyName() + ": "
            + TimeUnit.NANOSECONDS.toMillis( endTime - startTime ) + "ms. (" +
            ( TOTAL_WORK_BATCHES * SEARCHERS_PER_BATCH ) + " searches, " +
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.