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

x33g5p2x  于2022-01-18 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(145)

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

CyclicBarrier.getParties介绍

[英]Returns the number of parties required to trip this barrier.
[中]返回跳过此屏障所需的参与方数。

代码示例

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

@Test
public void testMultiSessionSparkContextReUse() throws MalformedURLException {
 String confDir = "../data/conf/spark/local/hive-site.xml";
 HiveConf.setHiveSiteLocation(new File(confDir).toURI().toURL());
 ExecutorService executor = Executors.newFixedThreadPool(barrier.getParties());
 List<CompletableFuture<Void>> futures =
   IntStream.range(0, barrier.getParties()).boxed()
     .map(i -> CompletableFuture.supplyAsync(() -> execute(i), executor))
     .collect(Collectors.toList());
 futures.forEach(CompletableFuture::join);
}

代码示例来源:origin: google/guava

+ 1 // for the blocking get thread,
      + 1); // for the main thread
final ExecutorService executor = Executors.newFixedThreadPool(barrier.getParties());
final AtomicReference<AbstractFuture<String>> currentFuture = Atomics.newReference();
final AtomicBoolean setFutureSuccess = new AtomicBoolean();
allTasks.add(setFutureCompleteSucessFullyRunnable);
allTasks.add(Executors.callable(collectResultsRunnable));
assertEquals(allTasks.size() + 1, barrier.getParties()); // sanity check
for (int i = 0; i < 1000; i++) {
 Collections.shuffle(allTasks);

代码示例来源:origin: google/guava

final ExecutorService executor = Executors.newFixedThreadPool(barrier.getParties());
final AtomicReference<AbstractFuture<String>> currentFuture = Atomics.newReference();
final AtomicReference<AbstractFuture<String>> setFutureFuture = Atomics.newReference();
assertEquals(allTasks.size() + 1, barrier.getParties()); // sanity check
for (int i = 0; i < 1000; i++) {
 Collections.shuffle(allTasks);

代码示例来源:origin: google/guava

+ 50 // for the blocking get threads,
      + 1); // for the main thread
final ExecutorService executor = Executors.newFixedThreadPool(barrier.getParties());
final AtomicReference<AbstractFuture<String>> currentFuture = Atomics.newReference();
final AtomicInteger numSuccessfulSetCalls = new AtomicInteger();
assertEquals(allTasks.size() + 1, barrier.getParties());
for (int i = 0; i < 1000; i++) {
 Collections.shuffle(allTasks);

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

public void acceptRegister() throws IOException {
    serverSocket = new ServerSocket(port);
    
    //prepare paramMap
    paramRanges = new ParameterRange[barrier.getParties()];
    hostnames = new String[barrier.getParties()];
    p.getWeights();
    
    
    //
    for(int i =0; i < barrier.getParties() ; i++) {
      Socket s = serverSocket.accept();
      RegisterThread t = new RegisterThread(s, i);
      t.start();
      threads.add(t);
    }
    
    for(int i = 0; i < threads.size(); i++) {
      try {
        threads.get(i).join();
      } catch (InterruptedException e) {
        System.err.println(String.format("Thread %d is interrupted..", i));
        e.printStackTrace();
      }
    }
  }
}

代码示例来源:origin: org.terracotta.management/sequence-generator

final int[][] counts = new int[barrier.getParties()][];
Thread[] threads = new Thread[barrier.getParties()];
for (int i = 0; i < barrier.getParties(); i++) {
 final int tid = i;
 counts[i] = new int[10];

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

final int myOrder = barrier.getParties() - n;
System.out.printf("Turn number: %s was %s%n", myOrder, threadName);

代码示例来源:origin: blazegraph/database

haLog.info("Awaiting barrier: #followerResponses="
    + barrierState.followerResponses.size() + ", #parties="
    + barrierState.barrier.getParties()
    + ", #joinedUUIDs="
    + barrierState.joinedServiceIds.length);

代码示例来源:origin: com.blazegraph/bigdata-core

haLog.info("Awaiting barrier: #followerResponses="
    + barrierState.followerResponses.size() + ", #parties="
    + barrierState.barrier.getParties()
    + ", #joinedUUIDs="
    + barrierState.joinedServiceIds.length);

代码示例来源:origin: com.google.guava/guava-tests

+ 1 // for the blocking get thread,
  + 1); // for the main thread
final ExecutorService executor = Executors.newFixedThreadPool(barrier.getParties());
final AtomicReference<AbstractFuture<String>> currentFuture = Atomics.newReference();
final AtomicBoolean setFutureSuccess = new AtomicBoolean();
allTasks.add(setFutureCompleteSucessFullyRunnable);
allTasks.add(Executors.callable(collectResultsRunnable));
assertEquals(allTasks.size() + 1, barrier.getParties());  // sanity check
for (int i = 0; i < 1000; i++) {
 Collections.shuffle(allTasks);

代码示例来源:origin: com.google.guava/guava-tests

+ 50 // for the blocking get threads,
  + 1); // for the main thread
final ExecutorService executor = Executors.newFixedThreadPool(barrier.getParties());
final AtomicReference<AbstractFuture<String>> currentFuture = Atomics.newReference();
final AtomicInteger numSuccessfulSetCalls = new AtomicInteger();
assertEquals(allTasks.size() + 1, barrier.getParties());
for (int i = 0; i < 1000; i++) {
 Collections.shuffle(allTasks);

代码示例来源:origin: com.google.guava/guava-tests

final ExecutorService executor = Executors.newFixedThreadPool(barrier.getParties());
final AtomicReference<AbstractFuture<String>> currentFuture = Atomics.newReference();
final AtomicReference<AbstractFuture<String>> setFutureFuture = Atomics.newReference();
assertEquals(allTasks.size() + 1, barrier.getParties());  // sanity check
for (int i = 0; i < 1000; i++) {
 Collections.shuffle(allTasks);

相关文章