当前位置: 首页 > news >正文

金融互助网站开发青建设厅官方网站

金融互助网站开发,青建设厅官方网站,报价小程序制作,wordpress 登录页美化GCD的基本使用: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {// dispatch_sync : 同步#xff0c;不具备开启线程的能力// dispatch_async : 异步#xff0c;具备开启线程的能力// 并发队列 #xff1a;多个任务可以同时执行// 串行队列 #xff1…GCD的基本使用: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {// dispatch_sync : 同步不具备开启线程的能力// dispatch_async : 异步具备开启线程的能力// 并发队列 多个任务可以同时执行// 串行队列 一个任务执行完后再执行下一个任务// 获得全局的并发队列dispatch_queue_t queue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);// 将 任务 添加 全局队列 中去 异步 执行dispatch_async(queue, ^{NSLog(-----下载图片1---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片2---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片3---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片4---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片5---%, [NSThread currentThread]);}); } GCD中队列的使用: // dispatch_sync : 同步不具备开启线程的能力 // dispatch_async : 异步具备开启线程的能力// 并发队列 多个任务可以同时执行 // 串行队列 一个任务执行完后再执行下一个任务// Foundation : OC // Core Foundation : C语言 // Foundation和Core Foundation框架的数据类型可以互相转换的//NSString *str 123; // Foundation //CFStringRef str2 (__bridge CFStringRef)str; // Core Foundation //NSString *str3 (__bridge NSString *)str2; // CFArrayRef ---- NSArray // CFDictionaryRef ---- NSDictionary // CFNumberRef ---- NSNumber// Core Foundation中手动创建的数据类型都需要手动释放 // CFArrayRef array CFArrayCreate(NULL, NULL, 10, NULL); // CFRelease(array); // // // CGPathRef path CGPathCreateMutable(); // CGPathRetain(path); // // CGPathRelease(path); // CGPathRelease(path); /**凡是函数名中带有create\copy\new\retain等字眼, 都应该在不需要使用这个数据的时候进行releaseGCD的数据类型在ARC环境下不需要再做releaseCF(Core Foundation)的数据类型在ARC\MRC环境下都需要再做release*/#import HMViewController.hinterface HMViewController ()endimplementation HMViewController- (void)viewDidLoad {[super viewDidLoad];}- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {[self asyncSerialQueue]; }/*** async -- 并发队列最常用* 会不会创建线程会一般同时开多条* 任务的执行方式并发执行*/ - (void)asyncGlobalQueue {// 获得全局的并发队列dispatch_queue_t queue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);// 将 任务 添加 全局队列 中去 异步 执行dispatch_async(queue, ^{NSLog(-----下载图片1---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片2---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片3---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片4---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片5---%, [NSThread currentThread]);}); }/*** async -- 串行队列有时候用* 会不会创建线程会一般只开1条线程* 任务的执行方式串行执行一个任务执行完毕后再执行下一个任务*/ - (void)asyncSerialQueue {// 1.创建一个串行队列dispatch_queue_t queue dispatch_queue_create(cn.heima.queue, NULL);// 2.将任务添加到串行队列中 异步 执行dispatch_async(queue, ^{NSLog(-----下载图片1---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片2---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片3---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片4---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片5---%, [NSThread currentThread]);});// 3.非ARC需要释放创建的队列 // dispatch_release(queue); }/*** async -- 主队列(很常用)*/ - (void)asyncMainQueue {// 1.主队列(添加到主队列中的任务都会自动放到主线程中去执行)dispatch_queue_t queue dispatch_get_main_queue();// 2.添加 任务 到主队列中 异步 执行dispatch_async(queue, ^{NSLog(-----下载图片1---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片2---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片3---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片4---%, [NSThread currentThread]);});dispatch_async(queue, ^{NSLog(-----下载图片5---%, [NSThread currentThread]);}); }/*** sync -- 主队列(不能用---会卡死)*/ - (void)syncMainQueue {NSLog(syncMainQueue----begin--);// 1.主队列(添加到主队列中的任务都会自动放到主线程中去执行)dispatch_queue_t queue dispatch_get_main_queue();// 2.添加 任务 到主队列中 异步 执行dispatch_sync(queue, ^{NSLog(-----下载图片1---%, [NSThread currentThread]);});dispatch_sync(queue, ^{NSLog(-----下载图片2---%, [NSThread currentThread]);});dispatch_sync(queue, ^{NSLog(-----下载图片3---%, [NSThread currentThread]);});NSLog(syncMainQueue----end--); }/**-------------------------------------华丽的分割线-----------------------------------------------------**//*** sync -- 并发队列* 会不会创建线程不会* 任务的执行方式串行执行一个任务执行完毕后再执行下一个任务* 并发队列失去了并发的功能*/ - (void)syncGlobalQueue {// 获得全局的并发队列dispatch_queue_t queue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);// 将 任务 添加到 全局并发队列 中 同步 执行dispatch_sync(queue, ^{NSLog(-----下载图片1---%, [NSThread currentThread]);});dispatch_sync(queue, ^{NSLog(-----下载图片2---%, [NSThread currentThread]);});dispatch_sync(queue, ^{NSLog(-----下载图片3---%, [NSThread currentThread]);});dispatch_sync(queue, ^{NSLog(-----下载图片4---%, [NSThread currentThread]);});dispatch_sync(queue, ^{NSLog(-----下载图片5---%, [NSThread currentThread]);}); }/*** sync -- 串行队列* 会不会创建线程不会* 任务的执行方式串行执行一个任务执行完毕后再执行下一个任务*/ - (void)syncSerialQueue {// 创建一个串行队列dispatch_queue_t queue dispatch_queue_create(cn.heima.queue, NULL);// 将 任务 添加到 串行队列 中 同步 执行dispatch_sync(queue, ^{NSLog(-----下载图片1---%, [NSThread currentThread]);});dispatch_sync(queue, ^{NSLog(-----下载图片2---%, [NSThread currentThread]);});dispatch_sync(queue, ^{NSLog(-----下载图片3---%, [NSThread currentThread]);});dispatch_sync(queue, ^{NSLog(-----下载图片4---%, [NSThread currentThread]);});dispatch_sync(queue, ^{NSLog(-----下载图片5---%, [NSThread currentThread]);}); }end  转载于:https://www.cnblogs.com/ZMiOS/p/4924219.html
http://www.yutouwan.com/news/438584/

相关文章:

  • 网站内容被攻击该怎么做万网人网站备案流程
  • 建立购物网站的目的甘肃做网站价格
  • 网站设计专业需要什么软件通过邮箱查注册网站
  • 怎么建设自己网站外网无法访问免费网上商城
  • 陕西中小企业网站建设推广wordpress插件管理
  • 邯郸市搞网站服务务的吗wordpress增加登录账户
  • 搜狐快站做淘宝客网站看课学校网站建设
  • 天津网站优化哪家好排名第一的手机清理软件
  • 网站整合discuz论坛如何搭建微网站
  • asp是网站开发吗wordpress模板安装后
  • 网站怎么做seo、中企动力app
  • 大连做网站优化价格订餐网站开发方案
  • ps做网站设计稿济南哪家公司做网站好
  • 网站英文版是怎么做的北京网站排名方案
  • 网站建设的整个流程什么网站做教育的比较多
  • 大连网站建设意动科技企业手机网站开通
  • 如何开网站做代销抖音排名优化
  • 威海住房和城乡建设厅网站photoshop制作网站海报
  • 个人养老金制度相关细则福州网站seo推广优化
  • 价格套餐网站如何做好线上销售
  • 企业网站代码模板网站建设 汇卓
  • 流量网站应该怎么做网站开发如何避开法律
  • 重庆建设银行网站怎么登陆自己的公司网站
  • 建设网站要买服务器html网站更新
  • 北京电商网站建设外包saas系统销售好做吗
  • 宁晋网站建设代理公司注册品牌
  • 做网站有个名字叫小廖7位数qq免费申请永久
  • 深圳住房和建设局网站咨询窗口苏州网站外包
  • 云浮网站网站建设给wordpress添加公告
  • 重庆颐众达网站网站过期会怎样解决