在此示例中,类继承自NSThread。它每10秒执行一次方法A,除非方法sleepFromBeginning延长时间:
- (void)main {
while (!terminate) {
sleep(10);
[self methodA]
}
}
- (void)sleepFromBeginning {
// todo: Interrupt sleep and loop once more without calling methodA. How?
}
如果不取消线程就会中断睡眠?