创建使用线程
NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(runThread) object:NULL];
[thread start];
-(void)runThread
{
NSLog(@" %@ ",[NSThread currentThread]);
}
[NSThread detachNewThreadSelector:@selector(runThread) toTarget:self withObject:NULL];
[self performSelectorInBackground:@selector(runThread) withObject:NULL];
相关方法
[NSThread mainThread]; // 获取主线程
[NSThread mainThread]; // 判断是否是主线程
NSThread *thread = [NSThread currentThread];
[thread isMainThread]; // 判断是否是主线程
thread.name = @"";// 线程名字
网友评论