In some cases, items can (safely) be pushed and pulled from the queue structure by multiple threads. For example, let's say you want only 5 simultaneous connections to a credit card processor. You can start 5 threads and check (wait) for items to appear in the queue. Credit card processing requests are placed in this queue structure by other threads, which will be processed as soon as possible. (This is simplified. There are many other considerations, such as waiting for a response, thread safety, concurrency, locking, developer mood, moon phase ...)
source share