https://developer.apple.com/library/content/documentation/General/Conceptual/ConcurrencyProgrammingGuide/OperationQueues/OperationQueues.html#//apple_ref/doc/uid/TP40008091-CH102-SW25

Dispatch groups are a way to block a thread until one or more tasks finish executing. You can use this behavior in places where you cannot make progress until all of the specified tasks are complete. For example, after dispatching several tasks to compute some data, you might use a group to wait on those tasks and then process the results when they are done. Another way to use dispatch groups is as an alternative to thread joins. Instead of starting several child threads and then joining with each of them, you could add the corresponding tasks to a dispatch group and wait on the entire group.

dispatch_group_enter(group);

dispatch_group_leave(group);

用于任务本身是异步的情况;

dispatch_group_wait(group, dispatch_time(DISPATCH_TIME_NOW, 4 * NSEC_PER_SEC));

用于阻塞当前线程等待任务结束。

dispatch_group_notify:

用于异步等待任务结束。

最新文章

  1. 【转】nginx中的ngx_cdecl
  2. ARP包分析(wireshark)
  3. Java 第13章 带参数的方法
  4. Leetcode 52 N-Queens II 回溯搜索
  5. Gradle学习系列之一——Gradle快速入门
  6. du -sh
  7. json返回日期格式化的解决
  8. 《Linux/Unix系统编程手册》读书笔记3
  9. Spark Streaming揭秘 Day5 初步贯通源码
  10. wpf数据自动树结构
  11. webService返回自定义类型的数据处理
  12. 如何使用Excel和Word编辑和打印条形码
  13. VS代码生成工具ReSharper发布8.1版本
  14. Core在类中注入
  15. android如何获取SHA1
  16. 如何解决代码中if…else 过多的问题
  17. sql server导出数据,远程连接失败,需要设置权限
  18. DOM操作插入新的子节点
  19. 教你写Makefile(很全,含有工作经验的)
  20. b2BuoyancyController 使用浮力

热门文章

  1. 在本地用命令行创建一个git仓库,并推送到远程
  2. jquery报表插件收藏 MARK
  3. Vue生命周期整理
  4. [android] 天气app布局练习
  5. Java 基础(7)——运算符
  6. springboot mybatis 使用多数据源
  7. 域对象中属性变更及感知session绑定的事件监听器
  8. <%@ page isELIgnored="false"%>的作用
  9. javascript获取元素样式值
  10. 软件项目技术点(7)——在canvas上绘制自定义图形