Dim*_*han 5 iphone multithreading objective-c ipad objective-c-blocks
现在我想了解gcd的概念.使用宏中心调度如何在我的应用程序中实现多线程.我有关于gcd概念的想法,但我不能将这个概念实现到我的应用程序.我需要一个简单的例子用块来理解多线程使用gcd.please帮助我...
Art*_*hur 18
好..最简单的例子)
您可以用任何方法编写此代码.例如
-(void) viewDidLoad {
[super viewDidLoad];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//Here your non-main thread.
NSLog (@"Hi, I'm new thread");
dispatch_async(dispatch_get_main_queue(), ^{
//Here you returns to main thread.
NSLog (@"Hi, I'm main thread");
});
});
}
Run Code Online (Sandbox Code Playgroud)