cocoa自动提供的多线程编程技术。
[selfperformSelectorInBackground:@selector(dowork)withObject:nil];[selfperformSelectorOnMainThread:@selector(dowork)withObject:nilwaitUntilDone:nil];
NSTread
GCD
dispatch_queue_tqueue =dispatch_queue_create("my.queue",DISPATCH_QUEUE_CONCURRENT);dispatch_async( queue, ^{
NSLog(@"nidaye");
});
//注意字符串用c语言写的,
dispatch_queue:执行处理的等待队列,FIFO
Seirial Dispatch Queue 等待现在执行写中处理结束;顺序执行。只用一个线程处理一个任务。
dispatch_queue_tserial =dispatch_queue_create("serial",NULL);
Concurrent Dispath Queue 不等待现在执行中处理结束。并行执行,使用多个线程处理多个任务。
dispatch_queue_tcurrent =dispatch_queue_create("current",DISPATCH_QUEUE_CONCURRENT);
网友评论