在使用NSOperationQueue进行多线程编程时,可通过[queue setMaxConcurrentOperationCount:5]来设置线程池中最多并行的线程数,在GCD中信号量机制也和它相似,可以控制并发的线程数量. 1.首先熟悉下几个函数 dispatch_semaphore_create 创建一个信号量,设置一个初始值dispatch_semaphore_signal 发送一个信号,信号通知,信号量+1dispatch_semaphore_wait 等待信号,信号量-1 当一个…