だから私は、後で呼び出すことで使用できるようにしたい新しい NSThread を開始していますperformSelector:onThread:...
。私が理解している方法から、そのメソッドはその呼び出しをそのスレッドの実行ループに追加するため、次の反復でこれらの呼び出しをすべてポップし、呼び出すものがなくなるまで呼び出します。したがって、この種の機能が必要です。つまり、すぐに呼び出せる作業の準備が整ったアイドル スレッドです。私の現在のコードは次のようになります。
- (void)doInitialize
{
mThread = [[NSThread alloc] initWithTarget:self selector:@selector(runThread) object:nil];
[mthread start];
}
- (void)runThread
{
NSAutoReleasePool *pool = [[NSAutoReleasePool alloc] init];
// From what I understand from the Google machine is that this call should start the
// runloop on this thread, but it DOESN'T. The thread dies and is un-callable
[[NSRunLoop currentRunLoop] run];
[pool drain];
}
- (void)scheduleSomethingOnThread
{
[self performSelector:@selector(hardWork) onThread:mThread withObject:nil waitUntilDone:NO];
}
しかし、スレッドは維持されず、performSelector:onThread は何もしません。これを正しい方法で行うにはどうすればよいですか?