Start of a new thread in Swift
func add(a: Int, _ b: Int) -> Int {
sleep(3)
return a + b
}
let queue = dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0)
dispatch_async(queue) {
let result = add(3, 5)
print("result: \(result)")
}
print("main thread")
//printed:
//main thread
//result: 8
- Log in to post comments