我运行一个函数doTask
在另一个线程象下面这样:杀死另一个线程在我的情况
NSThread *otherThread = [[NSThread alloc] initWithTarget:self
selector:@selector(doTask)
object:nil];
[otherThread start];
...
-(void)doTask{
...
}
什么是从当前线程杀otherThread
的正确方法?
我知道[otherThread cancel]
只是标志着otherThread
应该被杀但不是真的杀死它。
总是最好*要求*另一个线程终止,而不是*告诉*它。这样会更清洁。 – Droppy
是的,我明白了,但在我的情况下,我可以让其他线程终止? –
未知;这取决于类之间的关系。 – Droppy