I'm asking this related to this question: Using events on multithreading socket server
I´ve implemented a ConcurrentQueue
thinking it would be needed to avoid problems with multi-threading. When doing it I've noticed the only difference with the standard Queue
is in the Dequeue()
method, asking for an out
parameter.
It made me think the only protection is within the thread(s) dequeuing the object, is this true?
In my game I have a main thread processing my game logic then another thread per player that is doing the jobs of listening, serialising and sending data.
So my ConcurrentQueue
will be enqueued and dequeued by different threads but only one and always the same will call either enqueue or dequeue.
So I'm right thinking I'll be OK with a simple queue?
Is ConcurrentQueue
only needed when calling Dequeue()
simultaneously from multiple threads?