1.pthrad
//1.創(chuàng)建線程:傳入線程和要執(zhí)行的方法(run)
pthread_t thread;
pthread_create(&thread, NULL, run, NULL);
2.NSThrad
- (void)createThread3
{
[self performSelectorInBackground:@selector(run:) withObject:@"jack"];
}
- (void)createThread2
{
[NSThread detachNewThreadSelector:@selector(run:) toTarget:self withObject:@"rose"];
}
- (void)createThread1
{
// 創(chuàng)建線程
NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(run:) object:@"jack"];
// 啟動(dòng)線程
[thread start];
}
- (void)run:(NSString *)param
{
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者