Is there an implementation with a blocking queue for acceptance, but is limited by the maximum size. When the size of the queue reaches the specified maximum size, instead of a "put" lock, it removes the head element and inserts it. So put is not locked (), but take () is.
One use is that if I have a very slow consumer, the system will not crash (running out of memory), rather, this message will be deleted, but I do not want to block the manufacturer.
An example of this is the stock trading system. When you get a surge in stock / quotes trading data, if you haven’t consumed the data, you want to automatically throw away the old trading / stock quotes.
mjlee source
share