Skip to content

Instantly share code, notes, and snippets.

@yaoxinghuo
Created January 20, 2014 08:53
Show Gist options
  • Save yaoxinghuo/8516981 to your computer and use it in GitHub Desktop.
Save yaoxinghuo/8516981 to your computer and use it in GitHub Desktop.
objective c 多线程GCD
dispatch_queue_t serverDelaySimulationThread = dispatch_queue_create("com.xxx.serverDelay", nil);
dispatch_async(serverDelaySimulationThread, ^{
[NSThread sleepForTimeInterval:10.0];
dispatch_async(dispatch_get_main_queue(), ^{
//Your server communication code here
});
});
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[NSThread sleepForTimeInterval:5.0];//假装暂停5秒
dispatch_async(dispatch_get_main_queue(), ^{
//Your server communication code here
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment