I had come across the issue of deadlock in another language and wondered how to force this situation in LabVIEW.
A way to overcome race conditions in local variables is to use semaphores. This can be used to put a mutex around a block of code to prevent another block of code from executing. However there can be an instance when two semaphores can block each other out by not releasing in the correct order.
In this code I have an increment loop which cannot acquire semaphore 2 until the decrement loop releases it. However, the decrement loop cannot release semaphore 2 until the increment loop releases semaphore 1. This creates a deadlock situation where the threads are waiting on each other and the program hangs.
Enjoy!
Rob
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
The VI snipped has changed the local variables for value change property nodes!
Nice example Rob_Ward!