NSThread线程的状态-6

NSThread线程的状态-6_第1张图片
NSThread线程的状态-6_第2张图片

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

[NSThread detachNewThreadSelector:@selector(run)  toTarget : self withObject:nil];

}

- (void)run{

NSLog(@”---------”);

//让线程睡眠2秒(阻塞2秒)

//[NSThread sleepForTimeInterval:2];

//睡眠直到遥远的未来

//[NSThread sleepUntilDate:[NSDate distanceFuture]];

[NSThread sleepUntilDate:[NSDate datewithTimeIntervalSinceNow:2]];

NSlog(@”+++++++”);

}

- (void)run1{

For(NSInteger i = 0; i < 100; i++){

NSLog(@“-----%ld”,i);

If(i == 49 ){

[NSThread exit];//直接退出线程

}

}

}


NSThread线程的状态-6_第3张图片

你可能感兴趣的:(NSThread线程的状态-6)