Creating a concurrent queue in swift

Creating a concurrent queue
let concurrentQueue = DispatchQueue(label: "queuename", attributes: .concurrent)
concurrentQueue.sync {

}  
Create a serial queue
let serialQueue = DispatchQueue(label: "queuename")
serialQueue.sync { 

}
Get main queue asynchronously
DispatchQueue.main.async {

}
Get main queue synchronously
DispatchQueue.main.sync {

}
To get one of the background thread
DispatchQueue.global(qos: .background).async {

}
Xcode 8.2 beta 2:
To get one of the background thread
DispatchQueue.global(qos: .default).async {

}

DispatchQueue.global().async {
    // qos' default value is ´DispatchQoS.QoSClass.default`
}
DispatchQueue.global(qos: .background).async {
    // Background Thread
    DispatchQueue.main.async {
        // Run UI Updates or call completion block
    }
}
If you want to learn about using these queues .See this answer

Comments

Most popular posts

Exploring Background Execution Limits on Android Oreo

The Android Kotlin style guides

SQL injection in Android content providers and how to be protected

WKWebView advanced tutorial (catch JS events, access properties etc...) (Swift)

Using Realm Mobile Database with Swift 4.0 (Insert, Update, Delete, List)

Chronometer Tutorial With Example In Android Studio

Implementing a Custom Back Button in Swift

From Swift to Javascript and Back

How to clear all activity stack in Android

How To: Map, Reduce and Filter in Swift