斯威夫特 4.1。首先创建一个并发Queue
private let concurrentPhotoQueue = DispatchQueue(label: "App_Name", attributes: .concurrent)
现在将您的工作分派到并发队列
concurrentPhotoQueue.async(flags: .barrier) { [weak self] in
// 1
guard let weakSelf = self else {
return
}
// 2 Perform your task here
weakSelf.passingMsgIdsTofetchMsgss(messageIDs : msgIDBatches[0])
weakSelf.passingMsgIdsTofetchMsgss(messageIDs : msgIDBatches[1])
weakSelf.passingMsgIdsTofetchMsgss(messageIDs : msgIDBatches[2])
weakSelf.passingMsgIdsTofetchMsgss(messageIDs : msgIDBatches[3])
// 3
DispatchQueue.main.async { [weak self] in
// Update your UI here
}
}