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

Discussion

Which of these correctly declares a barrier for four parties?

  • A.CyclicBarrier b = new CyclicBarrier(4);
  • B.CyclicBarrier b = new CyclicBarrier();
  • C.CyclicBarrier b = CyclicBarrier.forParties(4);
  • D.CyclicBarrier b = new CyclicBarrier(4, TimeUnit.SECONDS);

Answer: A

The constructor takes the number of parties, with an optional Runnable to run when the barrier trips. There is no no-argument form, no static factory, and a TimeUnit belongs to the await call rather than to construction.

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

Post your comment

Please log in or register to post a comment.