java.util.concurrent.ForkJoinPool.shutdown()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中java.util.concurrent.ForkJoinPool.shutdown()方法的一些代码示例,展示了ForkJoinPool.shutdown()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ForkJoinPool.shutdown()方法的具体详情如下:
包路径:java.util.concurrent.ForkJoinPool
类名称:ForkJoinPool
方法名:shutdown

ForkJoinPool.shutdown介绍

[英]True when shutdown() has been called.
[中]调用shutdown()时为True。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
public void destroy() {
  if (this.forkJoinPool != null) {
    // Ignored for the common pool.
    this.forkJoinPool.shutdown();
    // Wait for all tasks to terminate - works for the common pool as well.
    if (this.awaitTerminationSeconds > 0) {
      try {
        this.forkJoinPool.awaitTermination(this.awaitTerminationSeconds, TimeUnit.SECONDS);
      }
      catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
      }
    }
  }
}

代码示例来源:origin: org.springframework/spring-context

@Override
public void destroy() {
  if (this.forkJoinPool != null) {
    // Ignored for the common pool.
    this.forkJoinPool.shutdown();
    // Wait for all tasks to terminate - works for the common pool as well.
    if (this.awaitTerminationSeconds > 0) {
      try {
        this.forkJoinPool.awaitTermination(this.awaitTerminationSeconds, TimeUnit.SECONDS);
      }
      catch (InterruptedException ex) {
        Thread.currentThread().interrupt();
      }
    }
  }
}

代码示例来源:origin: oracle/opengrok

@Override
public void close() {
  if (ctagsPool != null) {
    ctagsPool.shutdown();
  }
  if (forkJoinPool != null) {
    forkJoinPool.shutdown();
  }
  if (fixedExecutor != null) {
    fixedExecutor.shutdown();
  }
}

代码示例来源:origin: kilim/kilim

public void shutdown() {
  super.shutdown();
  pool.shutdown();
  timerService.shutdown();
}
private static String[] processArgs(String[] args,int offset) {

代码示例来源:origin: OryxProject/oryx

throw new IllegalStateException(e.getCause());
} finally {
 pool.shutdown();

代码示例来源:origin: OryxProject/oryx

throw new IllegalStateException(e.getCause());
} finally {
 pool.shutdown();

代码示例来源:origin: lenskit/lenskit

private void runJobGraph(int nthreads) {
  Preconditions.checkState(rootJob != null, "job graph not built");
  ForkJoinPool pool = new ForkJoinPool(nthreads);
  try {
    pool.invoke(rootJob);
  } catch (Throwable err) {
    logger.error("experiment failed", err);
    if (!continueAfterError) {
      Throwables.throwIfUnchecked(err);
      // will only happen if an undeclared checked exception slips through
      throw new UncheckedExecutionException(err);
    }
  } finally {
    pool.shutdown();
  }
}

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

forkJoinPool.shutdown();

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

forkJoinPool.shutdown();

代码示例来源:origin: palantir/atlasdb

@Test
public void testCreatingMultipleTablesAtOnce() throws InterruptedException {
  int threadCount = 16;
  CyclicBarrier barrier = new CyclicBarrier(threadCount);
  ForkJoinPool threadPool = new ForkJoinPool(threadCount);
  threadPool.submit(() ->
      IntStream.range(0, threadCount).parallel().forEach(i -> {
        try {
          barrier.await();
          slowTimeoutKvs.createTable(GOOD_TABLE, AtlasDbConstants.GENERIC_TABLE_METADATA);
        } catch (BrokenBarrierException | InterruptedException e) {
          // Do nothing
        }
      }));
  threadPool.shutdown();
  Preconditions.checkState(threadPool.awaitTermination(90, TimeUnit.SECONDS),
      "Not all table creation threads completed within the time limit");
  slowTimeoutKvs.dropTable(GOOD_TABLE);
}

代码示例来源:origin: org.apache.hadoop/hadoop-hdfs

/**
 * Update the count of each directory with quota in the namespace.
 * A directory's count is defined as the total number inodes in the tree
 * rooted at the directory.
 *
 * This is an update of existing state of the filesystem and does not
 * throw QuotaExceededException.
 */
void updateCountForQuota(int initThreads) {
 writeLock();
 try {
  int threads = (initThreads < 1) ? 1 : initThreads;
  LOG.info("Initializing quota with " + threads + " thread(s)");
  long start = Time.monotonicNow();
  QuotaCounts counts = new QuotaCounts.Builder().build();
  ForkJoinPool p = new ForkJoinPool(threads);
  RecursiveAction task = new InitQuotaTask(getBlockStoragePolicySuite(),
    rootDir.getStoragePolicyID(), rootDir, counts);
  p.execute(task);
  task.join();
  p.shutdown();
  LOG.info("Quota initialization completed in " + (Time.monotonicNow() - start) +
    " milliseconds\n" + counts);
 } finally {
  writeUnlock();
 }
}

代码示例来源:origin: locationtech/geogig

private void cleanupForkJoinPool() {
  if (forkJoinPool == SHARED_FORK_JOIN_POOL)
    return; // no need to clean up
  else
    forkJoinPool.shutdown(); // private pool needs cleaning
}

代码示例来源:origin: org.locationtech.geogig/geogig-core

private void cleanupForkJoinPool() {
  if (forkJoinPool == SHARED_FORK_JOIN_POOL)
    return; // no need to clean up
  else
    forkJoinPool.shutdown(); // private pool needs cleaning
}

代码示例来源:origin: thomasmueller/minperf

public void shutdown() {
  if (pool != null) {
    pool.shutdown();
  }
}

代码示例来源:origin: io.sphere.sdk.jvm/sdk-http-ahc-1_8

@Override
public void close() {
  asyncHttpClient.close();
  threadPool.shutdown();
}

代码示例来源:origin: io.sphere.sdk.jvm/sdk-http-ning-1_8

@Override
public void close() {
  asyncHttpClient.close();
  threadPool.shutdown();
}

代码示例来源:origin: kompics/kompics

@Override
public void shutdown() {
  pool.shutdown();
  try {
    if (!pool.awaitTermination(Kompics.SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS)) {
      Kompics.logger.warn("Failed orderly Kompics shutdown");
    }
  } catch (InterruptedException ex) {
    Kompics.logger.warn("Failed orderly Kompics shutdown", ex);
  }
}

代码示例来源:origin: lejon/T-SNE-Java

@Override
double[][] run(TSneConfiguration config) {
  gradientPool = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
  gradientCalculationPool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
  double [][] Y = super.run(config);
  gradientPool.shutdown();
  gradientCalculationPool.shutdown();
  return Y;
}

代码示例来源:origin: addthis/hydra

private void joinProcessors() {
  mapperPool.shutdown();
  try {
    if (!mapperPool.awaitTermination(task.getTaskFinishTimeout(), TimeUnit.SECONDS)) {
      throw new RuntimeException("Mapper pool did not terminate after " +
                    task.getTaskFinishTimeout() + " seconds.");
    }
  } catch (InterruptedException ex) {
    log.error("Interrupted while waiting for mapper pool termination.");
    Throwables.propagate(ex);
  }
}

代码示例来源:origin: cmu-phil/tetrad

@Override
public float[] compute(boolean biasCorrected) {
  float[] means = new float[numOfCols];
  ForkJoinPool pool = new ForkJoinPool(numOfThreads);
  pool.invoke(new MeanAction(data, means, 0, numOfCols - 1));
  pool.invoke(new VarianceAction(data, means, biasCorrected, 0, numOfCols - 1));
  pool.shutdown();
  return means;
}

相关文章

微信公众号

最新文章

更多

ForkJoinPool类方法