启动线程
-(void)start;
//进行就绪状态->运行状态.当线程任务完成是,自动进入死亡状态
堵塞状态(暂停)线程
+(void)sleepUntilDate:(NSDate *)date;
+(void)sleepForTimeInterval:(NSTimeInterval)ti;
强制暂停线程
+(void)exit;
//进入死亡状态
一旦线程停止(死亡)了,就不能再次启动任务;
-(void)test7
{
NSThread *thread=[[NSThread alloc] initWithTarget:self
selector:@selector(run4)
object:nil];
//启动放到调度线程池中,等待调度,进入就绪状态
[thread start];
}
-(void)run4
{
NSLog(@"%s",__func__);
//暂停2秒
[NSThread sleepForTimeInterval:5.0];
//暂停到指定的时间点
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:5.0]];
[NSThread exit];//强行终止 后面的代码也不会执行
NSLog(@"停止");
}