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.
精彩评论