共 6 篇文章
显示摘要每页显示  条
let queue = dispatch_queue_create("myQueue", DISPATCH_QUEUE_SERIAL) NSLog("之前 - %@", NSThread.currentThread()) dispatch_async(queue, { () -> Void in NSLog("sync之前 - %@", NSThread.currentThread()) dispatch_sync(queue, { () -> Void in NSLog("sync - %@", NSThread.currentT...
CADisplayLink 及定时器的使用。// displayLink是CADisplayLink对象,target是自己,回调是coCaller displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(doCaller:)];//看这个doCaller回调 [displayLink setFrameInterval: self.interval];//设置帧率 [displayLink addToRunLoop:[N...
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0);dispatch_source_set_event_handler(_timer, ^{dispatch_source_c...
关于@synchronized(self)的用法@synchronized 的作用是创建一个互斥锁,保证此时没有其它线程对self对象进行修改。If you execute the preceding method in two different threads, passing a different object for the anObj parameter on each thread, each would take its lock and continue processing without being blocked by the other.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{某个线程A调用lock方法。如果,在线程A 调用unlock方法之前,另一个线程B调用了同一锁对象的lock方法。三、使用GCD中dispatch_semaphore_t和dispatch_semaphore_wait.dispatch_semaphore_t semaphore = dispatch_semaphore_create(1);dispatch_semaphore_wai...
帮助 | 留言交流 | 联系我们 | 服务条款 | 下载网文摘手 | 下载手机客户端
北京六智信息技术股份有限公司 Copyright© 2005-2024 360doc.com , All Rights Reserved
京ICP证090625号 京ICP备05038915号 京网文[2016]6433-853号 京公网安备11010502030377号
返回
顶部