ConcurrentQueue<T> declare static?

194 views Asked by At

I want to use a shared list (ConcurrentQueue<T>) for my project, that includes a listener, a processor and a sender. The listener enqueues items to a list, the sender dequeues them from the same list (FIFO). The processor does some processing in between.

The idea is to start the listener and sender asynchronously and the processor synchronously, but they all access the same data structure (the ConcurrentQueue<T>).

Can I simply declare a static ConcurrentQueue<T> or do I need some locking strategy to avoid resource contention? My understanding is the ConcurrentQueue<T> is thread safe and I assume no other code is required. Is my understanding correct?

0

There are 0 answers