title: iphone - what is the logic of this kind of multithread operation
body: <p>I am just trying to understand this: multithread is a way of firing a method in another thread, so it will not hang the main thread (when something heavy must be done). But I have seen stuff like this:</p>
  
  <p>this goes on the main code:</p>
  
  <pre><code>[NSThread detachNewThreadSelector:@selector(createNewThread) toTarget:self withObject:nil];
  </code></pre>
  
  <p>and here goes the thread</p>
  
  <pre><code>-(void) createNewThread {
  
  NSAutoreleasePool* p = [[NSAutoreleasePool alloc] init];
  
  [self performSelectorOnMainThread:@selector(doSomeStuff) withObject:nil waitUntilDone:YES];
  
  [p release];
  }
  </code></pre>
  
  <p>My problem with this is: if the thread is intended to relieve the main thread from doing something, why is doSomeStuff being called using performSelectorOnMainThread? Isn't that insane? I mean, you fire a second thread just to run something on the main thread, a thread that in fact you shouldn't be using.</p>
  
  <p>I have seen a lot of code on the web write this way.</p>
  
  <p>I know that probably it is done that way because it is doing something that is not thread safe, but is doing this really useful? To me sounds that it is totally useless and it would be better to do something like </p>
  
  <pre><code>[self performSelector:@selector(doSomeStuff) withObject:nil afterDelay:0.01];
  </code></pre>
  
  <p>what do you guys think? 
  thanks in advance.</p>