GCD名词解释-01-GCD



屏幕快照 2016-04-21 06.52.02.png 
屏幕快照 2016-04-21 06.53.39.png
 
屏幕快照 2016-04-21 06.55.58.png
屏幕快照 2016-04-21 06.59.48.png
屏幕快照 2016-04-21 07.00.59.png
屏幕快照 2016-04-21 07.10.02.png
 
//
//  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

 

 
 
 
 
 
 
 
 
 

posted on 2016-04-21 07:15  爱你久久iOS  阅读(254)  评论(0编辑  收藏  举报

导航