首页 > 其他 > 详细

GCD名词解释-01-GCD

时间:2016-04-21 08:47:18      阅读:180      评论:0      收藏:0      [点我收藏+]



技术分享 
技术分享
技术分享
技术分享
 
技术分享
技术分享
技术分享
技术分享
技术分享
技术分享
技术分享
技术分享
 
//
//  ViewController.m
//  GCD
//
//  Created by mac on 16/4/21.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    /**
     *  1)dispatch_sync:同步,不具备开启线程的能力
        2)dispatch_async:异步,具备开启线程的能力
     
        并发队列:多个任务可以同时执行
        串行队列:多个任务,排队执行,一个任务执行完,再执行下一个任务
     */
    
    //获取并发的全局队列
    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    
    //将 任务 添加到 全局队列 中去 异步执行
    dispatch_async(queue, ^{
        
        NSLog(@"1111==%@", [NSThread currentThread]);
    });
    dispatch_async(queue, ^{
        
        NSLog(@"2222==%@", [NSThread currentThread]);
    });
    dispatch_async(queue, ^{
        
        NSLog(@"3333==%@", [NSThread currentThread]);
    });
    dispatch_async(queue, ^{
        
        NSLog(@"4444==%@", [NSThread currentThread]);
    });
    dispatch_async(queue, ^{
        
        NSLog(@"5555==%@", [NSThread currentThread]);
    });
}

@end

 

 
 
 
 
 
 
 
 
 

GCD名词解释-01-GCD

原文:http://www.cnblogs.com/foreveriOS/p/5415448.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!