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

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

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

ForkJoinPool.execute介绍

暂无

代码示例

代码示例来源:origin: fengjiachun/Jupiter

@Override
public void execute(Runnable r) {
  executor.execute(r);
}

代码示例来源:origin: fengjiachun/Jupiter

@Override
public void execute(Runnable r) {
  executor.execute(r);
}

代码示例来源:origin: goldmansachs/gs-collections

private FastList<ForkJoinTask<PT>> createAndExecuteTasks(ForkJoinPool executor, ProcedureFactory<PT> procedureFactory, List<T> list)
{
  FastList<ForkJoinTask<PT>> tasks = FastList.newList(this.taskCount);
  int sectionSize = list.size() / this.taskCount;
  int taskCountMinusOne = this.taskCount - 1;
  for (int index = 0; index < this.taskCount; index++)
  {
    ForkJoinTask<PT> task = this.createTask(procedureFactory, list, sectionSize, taskCountMinusOne, index);
    tasks.add(task);
    executor.execute(task);
  }
  return tasks;
}

代码示例来源:origin: goldmansachs/gs-collections

private FastList<ForkJoinTask<PT>> createAndExecuteTasks(ForkJoinPool executor, ObjectIntProcedureFactory<PT> procedureFactory, List<T> list)
{
  FastList<ForkJoinTask<PT>> tasks = FastList.newList(this.taskCount);
  int sectionSize = list.size() / this.taskCount;
  int taskCountMinusOne = this.taskCount - 1;
  for (int index = 0; index < this.taskCount; index++)
  {
    ForkJoinTask<PT> task = this.createTask(procedureFactory, list, sectionSize, taskCountMinusOne, index);
    tasks.add(task);
    executor.execute(task);
  }
  return tasks;
}

代码示例来源:origin: goldmansachs/gs-collections

private FastList<ForkJoinTask<PT>> createAndExecuteTasks(ForkJoinPool executor, ProcedureFactory<PT> procedureFactory, BatchIterable<T> iterable)
{
  FastList<ForkJoinTask<PT>> tasks = FastList.newList(this.taskCount);
  for (int index = 0; index < this.taskCount; index++)
  {
    ForkJoinTask<PT> voidBlockFJTask = new FJBatchIterableProcedureTask<>(this, procedureFactory, iterable, index, this.taskCount);
    tasks.add(voidBlockFJTask);
    executor.execute(voidBlockFJTask);
  }
  return tasks;
}

代码示例来源:origin: apache/kylin

try {
  BaseCuboidTask<T> task = new BaseCuboidTask<>(inputController, 1, resultWatcher);
  builderPool.execute(task);
  do {
    builderList.add(task.getInternalBuilder());

代码示例来源:origin: reactor/reactor-core

__ -> { },
() -> captureCompletion.set(true),
s -> ForkJoinPool.commonPool().execute(() ->
  RaceTestUtils.race(s::cancel, () -> s.request(1), Schedulers.parallel())

代码示例来源: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: habanero-rice/PCDP

/**
 * Run the provided task on the thread pool backing this runtime.
 * @param task Task to make eligible for execution.
 */
public static void submitTask(final BaseTask task) {
  taskPool.execute(task);
}

代码示例来源:origin: line/centraldogma

private void stopLater() {
  // Stop from an other thread so that it does not get stuck
  // when this method runs on an executor thread.
  ForkJoinPool.commonPool().execute(this::stop);
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server-shaded

private void stopLater() {
  // Stop from an other thread so that it does not get stuck
  // when this method runs on an executor thread.
  ForkJoinPool.commonPool().execute(this::stop);
}

代码示例来源:origin: org.jresearch.logui/org.jresearch.logui.backend

@Override
public void init() throws ServletException {
  // Warm the logger
  ForkJoinPool.commonPool().execute(Logs::getLoggers);
  // Create Object JSON mapper
  mapper = new ObjectMapper();
  LOGGER.trace("Init of LogUiServlet complete."); //$NON-NLS-1$
  super.init();
}

代码示例来源:origin: com.linecorp.centraldogma/centraldogma-server

private void stopLater() {
  // Stop from an other thread so that it does not get stuck
  // when this method runs on an executor thread.
  ForkJoinPool.commonPool().execute(this::stop);
}

代码示例来源:origin: peschlowp/ForkJoin

@Override
  protected void schedule(int actorId) {
  pool.execute(new ActorForkJoinTask(this, mailboxes[actorId]));
  }
}

代码示例来源:origin: org.kaazing/nuklei-core

public void spinUp(final Nukleus nukleus)
{
  Wrapper[] oldArray = nukleusArrayRef.get();
  Wrapper[] newArray = Arrays.copyOf(oldArray, oldArray.length + 1);
  newArray[oldArray.length] = new Wrapper(nukleus, pool);
  pool.execute(newArray[oldArray.length]);
  nukleusArrayRef.lazySet(newArray);
}

代码示例来源:origin: org.kaazing/nuklei-core

public void run()
  {
    final int weight = nukleus.process();
    idler.idle(weight);
    pool.execute(this);
  }
}

代码示例来源:origin: org.eclipse.collections/eclipse-collections-forkjoin

private FastList<ForkJoinTask<PT>> createAndExecuteTasks(ForkJoinPool executor, ProcedureFactory<PT> procedureFactory, BatchIterable<T> iterable)
{
  FastList<ForkJoinTask<PT>> tasks = FastList.newList(this.taskCount);
  for (int index = 0; index < this.taskCount; index++)
  {
    ForkJoinTask<PT> voidBlockFJTask = new FJBatchIterableProcedureTask<>(this, procedureFactory, iterable, index, this.taskCount);
    tasks.add(voidBlockFJTask);
    executor.execute(voidBlockFJTask);
  }
  return tasks;
}

代码示例来源:origin: net.oneandone.reactive/reactive-http

private final void tryScheduleToExecute() {
  try {
    ForkJoinPool.commonPool().execute(this);
  } catch (Throwable t) {
    close(); // no further notifying (executor does not work anyway)
    subscriber.onError(t);
  }
}

代码示例来源:origin: com.goldmansachs/gs-collections-forkjoin

private FastList<ForkJoinTask<PT>> createAndExecuteTasks(ForkJoinPool executor, ProcedureFactory<PT> procedureFactory, BatchIterable<T> iterable)
{
  FastList<ForkJoinTask<PT>> tasks = FastList.newList(this.taskCount);
  for (int index = 0; index < this.taskCount; index++)
  {
    ForkJoinTask<PT> voidBlockFJTask = new FJBatchIterableProcedureTask<>(this, procedureFactory, iterable, index, this.taskCount);
    tasks.add(voidBlockFJTask);
    executor.execute(voidBlockFJTask);
  }
  return tasks;
}

代码示例来源:origin: io.vertx/vertx-micrometer-metrics

private void runClientRequests(TestContext ctx) {
 Async clientsFinished = ctx.async(concurrentClients);
 for (int i = 0; i < concurrentClients; i++) {
  ForkJoinPool.commonPool().execute(() -> {
   NetClient client = vertx.createNetClient();
   request(client, ctx);
   clientsFinished.countDown();
  });
 }
 clientsFinished.awaitSuccess();
}

相关文章

ForkJoinPool类方法