Avoideded flushing the console output from inside a thread, which caused a crash