The following code
DispatchQueue.main.async {
print(Thread.current)
DispatchQueue.global().sync {
print(Thread.current)
}
}
prints
<_NSMainThread: 0x60000059c140>{number = 1, name = main}
<_NSMainThread: 0x60000059c140>{number = 1, name = main}
Technically, global queue finds an idle thread to run the task, which might be the main thread.
Is there any explicit rule indicates when a task added to global queue will be performed on main thread?
So time consuming tasks put in the global queue wouldn't affect the main thread.