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

Implementing a Custom Back Button in Swift

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

Chronometer Tutorial With Example In Android Studio

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

How to adjust image content mode using aspect fill, aspect fit and scaling

How to clear all activity stack in Android

From Swift to Javascript and Back

How To: Map, Reduce and Filter in Swift

Extension functions in Kotlin: Extend the Android Framework (KAD 08)

SQL injection in Android content providers and how to be protected