Create deadlock in Grand Central Dispatch

1.
dispatch_queue_t q = dispatch_queue_create("deadlock queue", DISPATCH_QUEUE_SERIAL);

NSLog(@"1");
dispatch_async(q, ^{
    NSLog(@"2");
    dispatch_sync(q, ^{
        NSLog(@"3");
    });
    NSLog(@"4");
});
NSLog(@"5");
2.
dispatch_sync(dispatch_get_current_queue(), ^{
    NSLog(@"-------");
});

你可能感兴趣的:(Create deadlock in Grand Central Dispatch)