Java Concurrency Interview

Synchronizers: latches, barriers, semaphores question 54 of 180 mid

Which synchroniser would you choose, and how do you decide?

The question behind the question is whether you reach for a primitive or for a queue, so answer with the decision rather than the list:

And the meta-answer that earns the point: if you can express it as a queue between threads, do that instead. A queue carries the data, provides the happens-before edge and gives you backpressure, which none of these primitives do on their own.

synchronizers design

Quiz yourself on Synchronizers: latches, barriers, semaphores Suggest a correction