异步线程中开启定时器

时间:2021-10-17 17:59:22

异步线程中开启定时器---

dispatch_queue_t concurrentDiapatchQueue=dispatch_queue_create("com.test.queue", DISPATCH_QUEUE_CONCURRENT);
    dispatch_async(concurrentDiapatchQueue, ^{
        [[NSRunLoop currentRunLoop] run];
        [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(reloadMainTab) userInfo:nil repeats:YES];
    });

需要开启[[NSRunLoop currentRunLoop] run];

 

如果不开启RunLoop

则不需要使用NSTimer ,使用GCD就行了!!