队列

//MARK:串行队列,异步任务
-(void)gcdDemo2
{
//1.队列-串行
/*
参数1:队列名称
参数2:队列属性 DISPATCH_QUEUE_SERIAL 串行,等价于NULL
*/
dispatch_queue_t q = dispatch_queue_create("CC_queue",NULL);

dispatch_queue_t serialQueue = dispatch_queue_create("com.snake", DISPATCH_QUEUE_CONCURRENT);

//2.异步执行任务 async
for(int i = 0;i < 10;i++)
{
dispatch_async(serialQueue,^{
    
    NSLog(@"currentThread:%@ I:%tu",[NSThread currentThread],i);

});
}

//它在主线程
NSLog(@"come here");

}

你可能感兴趣的:(队列)