When do you want to use a thread-safe stack?

I came across this question, and I was curious in what real situations do you really want to use a stack of several threads, as opposed to a FIFO queue, or a priority queue. It seems to me that it is very difficult for me to understand that the LIFO property is ever suitable for use in multiple threads. You really won’t have a guarantee that you are exiting the stack other than what was recently added. Wouldn't that lead to a serious starvation of old things in the stack / queue?

+4
source share
1 answer

I can imagine that this can be useful in a situation where the answer to the most recently arrived job is considered more useful. A model view with priority interruption, with older elements that need to be checked and processed in time.

I can imagine how the Stack Overflow bot restyler will be created that will work this way. A single-threaded entry takes a stream of new questions to the stack - a thread pool appears and quickly responds to the latter, and checks and answers older ones if it no longer has an acceptable answer and no more viable reputation opportunities through new questions coming in.

+2
source

All Articles