Saturday, 31 August 2013

Why will the following simple grand central dispatch program not work correctly?

Why will the following simple grand central dispatch program not work
correctly?

So I was expecting the following program to print two lines. However it
doesn't print anything. Any ideas on what needs to be fixed?
#import <Foundation/Foundation.h>
#import <dispatch/dispatch.h>
int main(int argc, char **argv)
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),
^{
printf("Done outer async\n");
dispatch_async(dispatch_get_main_queue(),^{
printf("Done inner sync");
});
});
return 0;
}
Thanks

No comments:

Post a Comment