title: NSThread sleepfortimeinterval blocks main thread
body: <p>I want to simulate a communication with a server. As the remote server will have some delays I want to use a background thread that has on it        </p>
  
  <pre><code> [NSThread sleepForTimeInterval:timeoutTillAnswer];
  </code></pre>
  
  <p>The thread is created with NSThread sub classing and started ... However I noticed that sleepForTimeInterval is blocking the main thread... Why??? Isn't a NSThread a backgroundThread by default? </p>
  
  <p>This is how the thread is created:</p>
  
  <pre><code>   self.botThread = [[PSBotThread alloc] init];
      [self.botThread start];
  </code></pre>
  
  <p>Further info:
  This is the bot thread subclas</p>
  
  <pre><code>- (void)main
  {
      @autoreleasepool {
          self.gManager = [[PSGameManager alloc] init];
          self.comManager = [[PSComManager alloc] init];
          self.bot = [[PSBotPlayer alloc] initWithName:@"Botus" andXP:[NSNumber numberWithInteger:1500]];
          self.gManager.localPlayer = self.bot;
          self.gManager.comDelegate = self.comManager;
          self.gManager.tillTheEndGame = NO;
          self.gManager.localDelegate = self.bot;
          self.comManager.gameManDelegate = self.gManager;
          self.comManager.isBackgroundThread = YES;
          self.comManager.logginEnabled = NO;
          self.gManager.logginEnabled = NO;
          self.bot.gameDelegate = self.gManager;
          BOOL isAlive = YES;
          // set up a run loop
          NSRunLoop *runloop = [NSRunLoop currentRunLoop];
          [runloop addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode];
          [self.gManager beginGameSP];
          while (isAlive) { // 'isAlive' is a variable that is used to control the thread existence...
              [runloop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
          }
  
  
  
      }
  }
  
  - (void)messageForBot:(NSData *)msg
  {
      [self.comManager didReceiveMessage:msg];
  }
  </code></pre>
  
  <p>I want to call "messageForBot" from the main thread... also the background thread should call a method on the main thread to communicate.. The sleep for time intervail in inside the gManager object ....  </p>