我想模拟与服务器的通信.由于远程服务器会有一些延迟,我想使用一个后台线程
[NSThread sleepForTimeInterval:timeoutTillAnswer];
线程使用NSThread子类创建并启动…但是我注意到sleepForTimeInterval阻塞主线程…为什么?默认情况下不是NSThread的backgroundThread?
这是线程的创建方式:
self.botThread = [[PSBotThread alloc] init];
[self.botThread start];
更多信息:
这是bot线程子句
- (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;