开发者社区> 问答> 正文

关于ios NSThread在start后的运行的问题

-(void)gogo:(NSString *)str{
    for (int i=0; i<100; i++) {
        NSLog(@"thread in gogo-->%@",[NSThread currentThread]);
        [NSThread sleepForTimeInterval:1.0f];
    }
}
-(void)startGo{
    NSThread *t1 = [[NSThread alloc]initWithTarget:self selector:@selector(gogo:) object:nil];
    [t1 start];
    NSLog(@"thread in startGo -->%@",[NSThread currentThread]);

thread线程已经start了,但是每次程序运行的时候都没有gogo这个方法里面的输出啊???
另外,当我换作[self performSelector之后,就可以看到在gogo中的循环输出了

展开
收起
爵霸 2016-03-19 14:31:44 1621 0
1 条回答
写回答
取消 提交回答
  • 没发现什么不妥,试了一下你的代码是可以走gogo这个方法的.

    2019-07-17 19:08:13
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
手淘iOS性能优化探索 立即下载
From Java/Android to Swift iOS 立即下载
深入剖析iOS性能优化 立即下载