title: NSThread Timing Problem with GUI
body: <p>I have a simple thread that runs an infinite loop. Eventually, the loop will check for serial data at a USB port a few thousand times per second, but at the moment, it just writes something to a custom class of NSTextView once every second.</p>
  
  <pre><code>int i;
  for (i=1; i&gt;0; i++)
  {
      [lock lock];
      [[self textStorage] replaceCharactersInRange:NSMakeRange([[self textStorage] length], 0) withString:@"test\n"];
      [lock unlock];
      sleep(1);
  }
  </code></pre>
  
  <p>The issue is that it writes really sporadically. It will do one or two, then wait ten seconds and spit ten of them out at once. If I replace the writing line with an <code>NSLog(@"test")</code>, it logs at nice even intervals. I have another test method in the main thread that accepts input into a text field and puts it into the text view, and doing this seems to update the text view to include the child thread's most recent writes. There shouldn't be anything interfering with it at this point anyway, but I've locked everything everywhere just to be sure. Thanks in advance.</p>