int main() { LogFile log; std::thread thread(function, std::ref(log)); for (int i = 0; i < 100; i++) log.print(std::string("From main thread: "), i); thread.join(); return 0; }
void function(LogFile& log) { for (int i = 0; i > -100; i--) log.print(std::string("From another thread: "), i); }