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

Chronometer Tutorial With Example In Android Studio

Exploring Background Execution Limits on Android Oreo

SQL injection in Android content providers and how to be protected

The Android Kotlin style guides

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

How to clear all activity stack in Android

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

From Swift to Javascript and Back

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