BOOL ifYouBack = false;
- (void)waitForYou{
dispatch_queue_t ourLifeQueue = dispatch_get_main_queue();
// dispatch_queue_t waitForYouQueue = dispatch_queue_create("I.AM.ALWAYS.HERE", DISPATCH_QUEUE_CONCURRENT);
dispatch_queue_t waitForYouQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(waitForYouQueue, ^{
while (![self ifYouback]) {
dispatch_sync(ourLifeQueue, ^{
NSLog(@"let's begin a happy life, 115-110-111-119");
});
}
});
while (![self ifYouback]) {
sleep(1);
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
while (![self ifYouback]) {
NSLog(@"do some thing for life");
}
});
}
}
- (BOOL)ifYouback{
return ifYouBack;
}
网友评论