← 返回 snapchat 的题目列表DispatchQueue Code Analysis in Swift
类型:online_judge
What is the output sequence and result of the following code snippet? Assume the current thread is the main thread. On which thread does each code block run?
let queue = DispatchQueue(label: "test")
queue.async {
print(1)
}
queue.sync {
print(2)
}
print(3)
Note: print(2) is on the main thread due to a Swift optimization.
Example
Input
current thread: main
Output
123