//
// main.m
// DispatchPrint
//
#import <Foundation/Foundation.h>
static void print_line(int i)
{
printf("%2d\n", i);
}
void dispatch_prints(void)
{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0);
dispatch_group_t group = dispatch_group_create();
for(int i = 0; i< 100; i++)
{
dispatch_group_async(group, queue, ^{print_line(i);});
}
dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
}
int main(int argc, const char * argv[]) {
@autoreleasepool {
dispatch_prints();
}
return 0;
}