美文网首页
NSThread线程的状态-6

NSThread线程的状态-6

作者: Sunney | 来源:发表于2016-05-26 09:53 被阅读25次

    -(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

          本文链接:https://www.haomeiwen.com/subject/fftxdttx.html