title: iPhone: how to use performSelector:onThread:withObject:waitUntilDone: method?
body: <p>I am trying to use a separate thread for working with some API.</p>
  
  <p>The problem is that I am not able to use <code>performSelector:onThread:withObject:waitUntilDone:</code> method with a thread that I' instantiated for this.</p>
  
  <p>My code:</p>
  
  <pre><code>@interface MyObject : NSObject {
    NSThread *_myThread;
  }
  @property(nonatomic, retain) NSThread *myThread;
  @end
  
  @implementation MyObject
  @synthesize myThread = _myThread;
  - (NSThread *)myThread {
    if (_myThread == nil) {
      NSThread *myThreadTemp = [[NSThread alloc] init];
      [myThreadTemp start];
      self. myThread = myThreadTemp;
      [myThreadTemp release];
    }
    return _myThread;
  }
  
  - (id)init {
    if (self = [super init]) {
      [self performSelector:@selector(privateInit:) onThread:[self myThread] withObject:nil waitUntilDone:NO];
    }
    return self;
  }
  - (void)privateInit:(id)object {
    NSLog(@"MyObject - privateInit start");
  }
  
  - (void)dealloc {
    [_myThread release];
    _myThread = nil;
    [super dealloc];
  }
  @end
  </code></pre>
  
  <p><code>"MyObject - privateInit start"</code> is never printed.<br/>
  What am I missing?</p>
  
  <p>I tried to instantiate the thread with target and selector, tried to wait for method execution completion (<code>waitUntilDone:YES</code>).<br/>
  Nothing helps.</p>
  
  <p>UPDATE:<br/>
  I don't need this multithreading for separating costly operations to another thread.<br/>
  In this case I could use the <code>performSelectorInBackground</code> as mentioned in few answers.<br/>
  The main reason for this separate thread is the need to perform all the actions in the API (TTS by Loquendo) from one single thread.<br/>
  Meaning that I have to create an instance of the TTS object and call methods on that object from the same thread all the time.</p>