<p style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono';"><pre name="code" class="objc"><pre name="code" class="objc" style="font-size: 18px; line-height: 24px;">DISPATCH_QUEUE_SERIAL:表示串行serial.asyn:是线程的名字,写什么都可以<pre name="code" class="objc" style="font-size: 18px; line-height: 24px;">dispatch_queue_t:是用来接收的串行队列,异步任务
<pre name="code" class="objc" style="font-size: 18px; line-height: 24px;">dispatch_queue_t q = dispatch_queue_create("serial.asyn", DISPATCH_QUEUE_SERIAL);<p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; font-family: 'Andale Mono';"><pre name="code" class="objc">dispatch_async(q, ^{
NSLog(@"%@", [NSThread currentThread]);
});
dispatch_queue_t q = dispatch_queue_create("cn.itcast.gcd2", DISPATCH_QUEUE_CONCURRENT);dispatch_sync(q, ^{
NSLog(@"%@ %d", [NSThread currentThread], i);
});然后在block里面写上你需要执行的代码就行了
2000



被折叠的 条评论
为什么被折叠?



