Use a mutex to ensures that only a single prints at the same time. this should prevent garbled terminal output and thus makes the it much easier to read. on the flipside, some race conditions may go unnoticed.