最近CyclicBarrierを学びましたが、ここで質問です:
コード:
public class Main {
public static CyclicBarrier c;
public static void main(String[] agrs){
int threadsCount = 5;
c = new CyclicBarrier(threadsCount + 1);
// make 5 A threads to run
}
}
public class A implements Runnable {
public void run(){
// do something
Main.c.await();
// do something
}
}
コードについてですが、メイン メソッドで await() を呼び出したことがないのに、(threadsCount) ではなく (threadsCount + 1) で CyclicBarrier を初期化する必要があるのはなぜでしょうか。