Giter Club home page Giter Club logo

ios-gcd's Introduction

IOS-GCD

iOS多线程--GCD

GCD的使用步骤其实很简单,只有两步。

创建一个队列(串行队列或并行队列) 将任务添加到队列中,然后系统就会根据任务类型执行任务(同步执行或异步执行) 下边来看看队列的创建方法和任务的创建方法。 // 1. 队列的创建 DISPATCH_QUEUE_SERIAL: 串行队列 DISPATCH_QUEUE_CONCURRENT: 并行队列 dispatch_queue_t queue1 = dispatch_queue_create("queue1", DISPATCH_QUEUE_SERIAL); dispatch_queue_t queue2 = dispatch_queue_create("queue2", DISPATCH_QUEUE_CONCURRENT);

// 2. 任务的创建
dispatch_sync(queue1, ^{ // 同步执行任务,不会创建新的线程
    NSLog(@"%@",[NSThread currentThread]);
});
dispatch_async(queue2, ^{ // 异步执行任务,会创建新的线程
    NSLog(@"%@",[NSThread currentThread]);
});

ios-gcd's People

Contributors

wangboecho avatar wb1357076878 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.