Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of these correctly declares a phaser for three registered parties?

  • A.Phaser p = new Phaser(3, TimeUnit.SECONDS);
  • B.Phaser p = new Phaser(3);
  • C.Phaser p = new Phaser();
  • D.Phaser p = Phaser.withParties(3);

Answer: B

The constructor takes the initial party count, and unlike CyclicBarrier that count can change afterwards with register and arriveAndDeregister. The no-argument form exists but starts with none registered, and there is no static factory.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.