开发者

If implementation a producer/consumer model, what's the best data structure to use?

开发者 https://www.devze.com 2023-02-23 03:29 出处:网络
I thought a queue shou开发者_StackOverflowld be OK, the producer push back and the consumer take from front. Is there any other thoughts like thread safety etc?If you are using a queue inside of a mul

I thought a queue shou开发者_StackOverflowld be OK, the producer push back and the consumer take from front. Is there any other thoughts like thread safety etc?


If you are using a queue inside of a multithreaded environment, I suggest a ConcurrentLinkedQueue. This will manage all the synchronization for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消