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

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

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

ForkJoinPool.awaitQuiescence介绍

暂无

代码示例

代码示例来源:origin: jankotek/mapdb

/**
 * Finds missing PoolCleaners
 */
void checkForkJoinPoolThreadLeaks() throws InterruptedException {
  Thread[] survivors = new Thread[7];
  int count = Thread.enumerate(survivors);
  for (int i = 0; i < count; i++) {
    Thread thread = survivors[i];
    String name = thread.getName();
    if (name.startsWith("ForkJoinPool-")) {
      // give thread some time to terminate
      thread.join(LONG_DELAY_MS);
      if (thread.isAlive())
        tearDownFail("Found leaked ForkJoinPool thread thread=%s",
               thread);
    }
  }
  if (!ForkJoinPool.commonPool()
    .awaitQuiescence(LONG_DELAY_MS, MILLISECONDS))
    tearDownFail("ForkJoin common pool thread stuck");
}

代码示例来源:origin: ben-manes/caffeine

@Override
protected boolean matchesSafely(Object ignored, Description description) {
 DescriptionBuilder desc = new DescriptionBuilder(description);
 if (context.removalListenerType == Listener.CONSUMING) {
  List<RemovalNotification<Integer, Integer>> notifications = context.consumedNotifications();
  ForkJoinPool.commonPool().awaitQuiescence(10, TimeUnit.SECONDS);
  int size = 0;
  for (RemovalNotification<?, ?> notification : notifications) {
   if (notification.getCause() == cause) {
    checkNotification(notification);
    size++;
   }
  }
  desc.expectThat("notification count", size, is(count));
 }
 return desc.matches();
}

代码示例来源:origin: ben-manes/caffeine

@Override
protected boolean matchesSafely(CacheContext context, Description description) {
 if (!context.isRecordingStats()) {
  return true;
 }
 CacheStats stats = context.stats();
 desc = new DescriptionBuilder(description);
 ForkJoinPool.commonPool().awaitQuiescence(10, TimeUnit.SECONDS);
 switch (type) {
  case HIT:
   return desc.expectThat(type.name(), stats.hitCount(), is(count)).matches();
  case MISS:
   return desc.expectThat(type.name(), stats.missCount(), is(count)).matches();
  case EVICTION_COUNT:
   return desc.expectThat(type.name(), stats.evictionCount(), is(count)).matches();
  case EVICTION_WEIGHT:
   return desc.expectThat(type.name(), stats.evictionWeight(), is(count)).matches();
  case LOAD_SUCCESS:
   return desc.expectThat(type.name(), stats.loadSuccessCount(), is(count)).matches();
  case LOAD_FAILURE:
   return desc.expectThat(type.name(), stats.loadFailureCount(), is(count)).matches();
  default:
   throw new AssertionError("Unknown stats type");
 }
}

代码示例来源:origin: com.oracle.substratevm/svm

private void initAllClasses() {
  final ForkJoinPool executor = new ForkJoinPool(Runtime.getRuntime().availableProcessors());
  Set<Path> uniquePaths = new TreeSet<>(Comparator.comparing(ImageClassLoader::toRealPath));
  uniquePaths.addAll(
          Arrays.stream(classpath)
                  .flatMap(ImageClassLoader::toClassPathEntries)
                  .collect(Collectors.toList()));
  uniquePaths.parallelStream().forEach(path -> loadClassesFromPath(executor, path));
  executor.awaitQuiescence(CLASS_LOADING_TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
}

代码示例来源:origin: stackoverflow.com

ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.DAYS);

代码示例来源:origin: stackoverflow.com

"ForkJoinPool-1-worker-1" [...] Object.wait() [...]
  java.lang.Thread.State: WAITING (on object monitor)
 [...]
 at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:995)
 [...]
 at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

[...]

"main" [...] waiting on condition [...]
  java.lang.Thread.State: WAITING (parking)
 [...]
 at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231)
 [...]
 at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1445)
 at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
 at java.util.concurrent.ForkJoinPool.awaitQuiescence(ForkJoinPool.java:3097)
 [...]

代码示例来源:origin: stackoverflow.com

pool.awaitQuiescence(2L, TimeUnit.SECONDS);

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) {
  // the default `commonPool` should be sufficient for many cases.
  ForkJoinPool pool = ForkJoinPool.commonPool(); 
  // The root of your task that may spawn other tasks. 
  // Make sure it submits the additional tasks to the same executor that it is in.
  Runnable rootTask = new YourTask(pool); 
  pool.execute(rootTask);
  pool.awaitQuiescence(...);
  // that's it.
}

代码示例来源:origin: CoffeePartner/capt

walker.visitTargets(asFactory(transforms), Util.await(future));
} else {
  pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.NANOSECONDS);

代码示例来源:origin: octo-online/reactive-audit

@Test(expected = CPUReactiveAuditException.class)
public void awaitQuiescence()
    throws InterruptedException
{
  TestTools.strict.commit();
  e.awaitQuiescence(1, TimeUnit.MILLISECONDS);
}

代码示例来源:origin: CoffeePartner/capt

pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
inner.providers.forEach(i -> pool.execute(() -> i.processor().onProcessEnd()));
pool.awaitQuiescence(Long.MAX_VALUE, TimeUnit.NANOSECONDS);

代码示例来源:origin: kamax-matrix/mxisd

ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.MINUTES);
}));

代码示例来源:origin: kousen/java_8_recipes

@Test
  public void awaitQuiesence() {
    CompletableFuture<Void> cf = aq.supplyThenAccept();
    assertFalse(cf.isDone());

    ForkJoinPool.commonPool().awaitQuiescence(1, TimeUnit.SECONDS);
    assertTrue(cf.isDone());
  }
}

相关文章

ForkJoinPool类方法