Threadsafe FIFO Queue/Buffer

前端 未结 5 1432
无人及你
无人及你 2020-12-18 00:55

I need to implement a sort of task buffer. Basic requirements are:

  • Process tasks in a single background thread
  • Receive tasks from multiple threads
5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-18 01:35

    You should think about ConcurrentQueue, which is FIFO, in fact. If not suitable, try some of its relatives in Thread-Safe Collections. By using these you can avoid some risks.

提交回复
热议问题