Is there any good documention on how many threads are created by GCD? At WWDC, they told us it\'s modeled around CPU cores. However, if I call this example:
<
Number of busy threads is equal to CPU cores. Blocked threads (you block them with sleepForTimeInterval) are not counted.
If you change your code to this (Swift):
for _ in 1..<30000 {
DispatchQueue.global().async {
while true {}
}
}
you'll see that there are just 2 threads created (on iPhone SE):
There is a thread limit so that your app is not killed because of big memory consumption if you have problem with blocked threads (usually because of deadlock).
Never block threads and you'll have them as much as your cores.