Is it possible to use Go's buffered channel as a thread-safe queue?

前端 未结 3 624
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-10 11:34

I want to find a queue structure (a data container) whose elements must be first-in-first-out. It is important for me that the structure must be thread-safe. I\'m going to u

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-10 12:13

    In Go, a buffered channel is just that: a thread-safe FIFO queue so what you are trying to do is perfectly valid. You shouldn't have performance issues at all with this approach.

提交回复
热议问题