I was asked this question in a big bank IV.
Q: if our queue needs to be as fast as possible, we want to avoid a global lock. How?
%%A1: multi-queue, based on cusip or account prefix. I implemented this partially in a JPM take-home coding test
%%A2: if were are very sure the queue is never depleted, then use 2 locks at both ends, so consumer threads only need to contend for the consumer lock.
%%A3: lock free queues are probably quite common in c#, java and c++
I feel in reality, there is usually some bound on the capacity of producer, consumer or queue. Sometimes producer will be too fast (overflow), or too slow (cross), so a queue without any bound check is unreliable in practice.