[self performSelectorInBackground:@selector(multiThread) withObject:nil];
- (void)multiThread {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//此种方式创建的timer已经添加至runLoop
// [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
//此种方式创建的timer没有添加至runLoop
NSTimer *timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
//将定时器添加到RunLoop中
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
[pool release];
[[NSRunLoop currentRunLoop] run];
NSLog(@"线程结束");
}
- (void)timerAction {
NSLog(@"timerAction");
}