Package java.util.concurrent

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


    for ( int i = 0; i < THREAD_NUMBER; i++ ) {
      threadPool.execute( new Task( searchFactory, i ) );
    }
    threadPool.shutdown();
    //Time to warmup only:
    threadPool.awaitTermination( WARM_UP_SECONDS, TimeUnit.SECONDS );
    System.out.println( "Warmup complete. Start measuring now..");
    //Start measuring:
    cyclesCompleted.set( 0 );
    long startMeasurementTime = System.nanoTime();
    threadPool.awaitTermination( FULL_RUN_SECONDS, TimeUnit.SECONDS );
View Full Code Here


    threadPool.awaitTermination( WARM_UP_SECONDS, TimeUnit.SECONDS );
    System.out.println( "Warmup complete. Start measuring now..");
    //Start measuring:
    cyclesCompleted.set( 0 );
    long startMeasurementTime = System.nanoTime();
    threadPool.awaitTermination( FULL_RUN_SECONDS, TimeUnit.SECONDS );
    int doneCycles = cyclesCompleted.get();
    long endMeasurementTime = System.nanoTime();
    Assert.assertFalse( "Some failure happened in Task execution", failures.get() );
    long totalTime = endMeasurementTime - startMeasurementTime;
    long millisecondsElapsedTime = TimeUnit.MILLISECONDS.convert( totalTime, TimeUnit.NANOSECONDS );
View Full Code Here

      for ( DoAddClasses runnable : runnables ) {
        assertNotNull( "Threads not run # " + runnable.getWorkNumber(), runnable.isFailure() );
        assertFalse( "thread failed #" + runnable.getWorkNumber() + " Failure: " + runnable.getFailureInfo(), runnable.isFailure() );
      }

      poolExecutor.awaitTermination( 1, TimeUnit.MINUTES );

      for ( int i = 0; i < nbrOfThread * nbrOfClassesPerThread; i++ ) {
        Query luceneQuery = parser.parse( "Emmanuel" + i );
        final Class<?> classByNumber = getClassByNumber( i, sf.getServiceManager() );
        IndexReader indexReader = sf.getIndexReaderAccessor().open( classByNumber );
View Full Code Here

    inputScanner.close();

    executor.shutdown();
    while (!executor.isTerminated()) {
      log.info("Pending tasks: ", workQueue.size());
      executor.awaitTermination(60, TimeUnit.SECONDS);
    }

    log.info("Done.");
  }
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

    Thread.sleep(timeoutMillis + 100);
    Assert.assertTrue(es.getMaximumPoolSize() == numMaxThreads);
    Assert.assertTrue(es.getPoolSize() == 0);

    es.shutdown();
    es.awaitTermination(timeoutMillis + 1, TimeUnit.MILLISECONDS);
  }

}
View Full Code Here

                    // sample all resources with threadpool
                    final List<Future<HTTPSampleResult>> retExec = exec.invokeAll(liste);
                    // call normal shutdown (wait ending all tasks)
                    exec.shutdown();
                    // put a timeout if tasks couldn't terminate
                    exec.awaitTermination(AWAIT_TERMINATION_TIMEOUT, TimeUnit.SECONDS);

                    // add result to main sampleResult
                    for (Future<HTTPSampleResult> future : retExec) {
                        final HTTPSampleResult binRes = future.get();
                        res.addSubResult(binRes);
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

        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

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

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.