开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜