方法一
dispatch_async(dispatch_get_global_queue(0, 0), ^{
self.timer = [NSTimer timerWithTimeInterval:3 repeats:YES block:^(NSTimer * _Nonnull timer) {
NSLog(@"定时器启动了 %@", [NSThread currentThread] );
}];
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSDefaultRunLoopMode];
[[NSRunLoop currentRunLoop] run];
});
方法二
dispatch_async(dispatch_get_global_queue(0, 0), ^{
self.timer = [NSTimer scheduledTimerWithTimeInterval:6 repeats:YES block:^(NSTimer * _Nonnull timer) {
NSLog(@"定时器启动了 %@", [NSThread currentThread] );
}];
[self.timer fire];
[[NSRunLoop currentRunLoop] run];
});