To run Loop and SecondLoop concurrency, you need to do something like:
#include <iostream> #include <thread> void Loop() { while(true) { //(do something) } } void SecondLoop() { while(true) { //(do something) } } int main() { std::thread t1(Loop); std::thread t2(SecondLoop); t1.join(); t2.join(); }
as join block the current thread to wait for another thread to finish.
source share