title: When mutex lock isn't enough?
body: <p>I know multithreaded programming is supposed to be hard. But it seems things find a weird way of breaking. For instance, I have multiple threads both changing the colors of and writing to the console (its an error log).</p>
  
  <p>There were 2 problems:</p>
  
  <ul>
  <li>jambled text</li>
  <li>color changes interfering/not at the right times</li>
  </ul>
  
  <p>When I added a mutex lock to the section that changes console color and writes to the console, it helped with the jambled text (haven't seen any since the mutex lock) but the console color is still wrong.</p>
  
  <p>So it appears a mutex is not enough!  I am now thinking I will need a queue, and a single thread that waits on that queue and flushes it out when there's stuff in it. So my question is, how do you gauge when a mutex lock is enough?  As soon as pipes/files/comm w/ another process is involved?</p>