The following code:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
for (int i=0; i<100000; i++) {
NSLog(@"HIGH 1 %d", i);
}
});
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
for (int i=0; i<100000; i++) {
NSLog(@"LOW %d", i);
}
});
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
for (int i=0; i<100000; i++) {
NSLog(@"HIGH 2 %d", i);
}
});
results in mixture of high 1, high 2 and low logs.
How is it that it prints high1 and high2 logs simultaneously. aren't both high1 and high2 blogs on the same queue? So shouldn't high1 block finish before starting to execute high2 block?