共 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... 阅17 转0 评0 公众公开 16-05-25 20:08 |
CADisplayLink 及定时器的使用。// displayLink是CADisplayLink对象,target是自己,回调是coCaller displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(doCaller:)];//看这个doCaller回调 [displayLink setFrameInterval: self.interval];//设置帧率 [displayLink addToRunLoop:[N... 阅343 转0 评0 公众公开 16-05-03 17:33 |
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... 阅2 转自ccccshq 公众公开 16-03-18 14:21 |
关于@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. 阅62 转0 评0 公众公开 16-03-01 16:16 |
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... 阅271 转0 评0 公众公开 16-02-29 17:01 |