Created
January 20, 2014 08:53
-
-
Save yaoxinghuo/8516981 to your computer and use it in GitHub Desktop.
objective c 多线程GCD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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