title: How to prevent input text breaking while other thread is outputting to the console?
body: <p>I have 2 threads: one of them is constantly cout'ing to the console some value, let's say increments an int value every second - so every second on the console is 1,2,3... and so on.</p>
  
  <p>Another thread is waiting for user input - with the command cin.</p>
  
  <p>Here is my problem: when I start typing something, when the time comes to cout the int value, my input gets erased from the input field, and put into the console with the int value. So when I want to type in "hello" it looks something like this:</p>
  
  <pre><code>1
  2
  3
  he4
  l5
  lo6
  7
  8
  </code></pre>
  
  <p>Is there a way to prevent my input from getting put to the console, while other thread is writing to the console? </p>
  
  <p>FYI this is needed for a chat app at client side - one thread is listening for messages and outputs this message as soon as it comes in, and the other thread is listening for user input to be sent to a server app.</p>