- 直接创建
// 创建一个子线程
NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(test:) object:@"子线程跑起来啦"];
// 给子线程命名
thread.name = @"czy-thread";
// 启动线程
[thread start];
- 创建线程后自动启动
// 直接开启一个子线程运行
[NSThread detachNewThreadSelector:@selector(test:) toTarget:self withObject:@"xxx"];
- 创建后台线程
[self performSelectorInBackground:@selector(download) withObject:nil];