Break a secondary thread loop immediately depending on the value of a variable set by the main loop
I’m encountering a concurrency problem in C++ that I’m struggling to find the best solution for. I have two threads: one is the main program, and the other is responsible for controlling the lights of my device. Here’s the code for my second thread: