23 lines · cpp
1#include <thread>2#include <chrono>3 4void usleep_helper(unsigned int usec) {5 // Break here in the helper6 std::this_thread::sleep_for(std::chrono::duration<unsigned int, std::milli>(usec));7}8 9void *background_thread(void *arg) {10 (void) arg;11 for (;;) {12 usleep_helper(2);13 }14}15 16int main(void) {17 unsigned int main_usec = 1;18 std::thread main_thread(background_thread, nullptr); // Set bkpt here to get started19 for (;;) {20 usleep_helper(main_usec);21 }22}23