search

Home  >  Q&A  >  body text

ios - GCD如何利用for循环开启多个线程

for (int i = 0; i < 3 ; i++) {
    dispatch_queue_t queue = dispatch_queue_create(<#const char *label#>, <#dispatch_queue_attr_t attr#>)
    dispatch_async(queue, ^{
        BSLog(@"当前线程为 : %@", [NSThread currentThread]);
    });
                
}

类似以上的代码,queue我不晓得该怎么写了,求教,万分感谢

PHPzPHPz2892 days ago329

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 09:21:50

    It seems that you have confused the concepts of queue and thread. . .
    Whether the queue is serial or parallel determines how the blocks inside are executed
    Multiple queues do not necessarily correspond to multiple threads

    reply
    0
  • Cancelreply