LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Documentation says one thread writes to the thread safe queue and one thread reads from it.

How many threads can write to the thread safe queue simultaneously?
0 Kudos
Message 1 of 3
(3,218 Views)
I believe that you can set up as many threads that write to and read from the thread safe queue, as it is protected internally from simultaneous access of the data.

Daniel McChane
Application Engineering
National Instruments
0 Kudos
Message 2 of 3
(3,218 Views)
While you CAN write to a thread safe queue from multiple threads, it is rarely a good program design. Usually the reader needs to know which thread the data is coming from in order to know what to do with it. If you have multiple writers to the same queue, not only will you have trouble identifying the source of the data (unless you embed some type of identifier in the data), but you will also have undeterministic timing since the writer threads are not synchronized.

Your application may have a need for this, but I would suggest considering multiple TSQs instead of multiple writers to a single queue as a potentially better option.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 3 of 3
(3,218 Views)