【发布时间】:2018-10-07 02:55:44
【问题描述】:
我知道队列的创建并且能够执行单个任务,但是我如何并行执行多个任务。
并发队列---->
let concurrentQueue = DispatchQueue(label: "com.some.concurrentQueue", attributes: .concurrent)
concurrentQueue.async {
//executable code
}
默认没有优先级的BackgroundQueue--->
DispatchQueue.global().async {
//executable code
}
具有优先级的后台队列---->
DispatchQueue.global(qos: .userInitiated).async { //.userInteractive .background .default .unspecified
//executable code
}
回到主队列---->
DispatchQueue.main.async {
//executable code
}
所有都是异步的,但是我如何一次执行多个方法我应该如何快速编码。
【问题讨论】:
-
请不要试图通过编辑问题文本来删除您的问题。如果您有正当理由希望删除该问题,您应该向版主或网站管理员寻求帮助,请参阅meta.stackoverflow.com/questions/305484/… 了解更多信息。
标签: ios swift multithreading swift4 dispatch-queue