ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Transfering data between threads

What is the best way to transfer data between 2 or more individually running threads?  Like say you have 2 threads running the first thread continuous processes data and sends it to the second thread which formats and graphs the data.  I know globals are an option, but I also know that they may not be the most efficient option.  Any thoughts on this are much appreciated.

Thanks,
Nate

0 Kudos
Message 1 of 5
(3,117 Views)
I prefer using Queues, see the producer/consumer model provided as a template with LV 7.0 and above.  I would avoid globals, and use a synchronization technique unless the loops are asynchronous (then maybe just use a local variable),
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 2 of 5
(3,112 Views)
Yes I agree with using queues when the threads are in the same vi, but what about when you have threads in seperate vi's altogether?

0 Kudos
Message 3 of 5
(3,110 Views)
The threads need not be in the same vi at all to use queues, you can create a queue in one vi and pass it as a reference to many subvi's and use just the same I will attach an example later.  If we were limited ro a single vi we would be in a bunch of trouble.
 
Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 4 of 5
(3,107 Views)
Here is an example in 7.0,  I use this format often.  Sorry about the sloppy coding but its lunch time and the only free time i had to fit this example in, hope it helps. 
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 5 of 5
(3,102 Views)