iOS

慢慢补充中...

1. 获取主线程

dispatch_queue_t mainQueue = dispatch_get_main_queue();

2. 用 dispatch_after做延时操作

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), mainQueue, ^{
        // type your code here
    });

3. 开启异步线程

dispatch_async(mainQueue, ^{
        // type your code here
    });

4. 开启后台线程

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT0), ^{
        // type your code here
    });

Swift中的用法

DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()+0.1) {

}

原文地址:https://www.cnblogs.com/staRR-k2/p/5015683.html