#include <stdio.h>
#include <chrono>
#include <thread>
using std::chrono::microseconds;
volatile int g_thread_2_continuing = 0;
void *
thread_1_func (void *input)
{
while (!g_thread_2_continuing)
{
std::this_thread::sleep_for(microseconds(1));
}
return NULL;
}
void *
thread_2_func (void *input)
{
int child_thread_continue = 0;
while (!child_thread_continue)
{
std::this_thread::sleep_for(microseconds(1));
}
g_thread_2_continuing = 1;
return NULL;
}
int main(int argc, char const *argv[])
{
lldb_enable_attach();
std::thread thread_1(thread_1_func, nullptr);
int main_thread_continue = 0;
while (!main_thread_continue)
{
std::this_thread::sleep_for(microseconds(1));
}
std::thread thread_2(thread_2_func, nullptr);
thread_1.join();
thread_2.join();
printf("Exiting now\n");
}