-(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中的循环输出了
没发现什么不妥,试了一下你的代码是可以走gogo这个方法的.
是不是用了ARC?如果用了,你的 t1还来不及干什么就会被释放。
我把你代码拷过来,运行,是对的啊。你再仔细看看。