ios - NSThread Programming issues -
i learning ios threading programming... encountered issue:
here comes code, please kindly have look:
int main(int argc, const char * argv[]) { @autoreleasepool { nsthread *t1 = [[nsthread alloc]initwithtarget:[mythread class] selector:@selector(mymethod:) object:nil]; [t1 start]; } return 0; } #import "mythread.h" @implementation mythread + (void)mymethod:(id)param { @autoreleasepool { nslog(@"called..."); } } @end
however, when ran program, though there no error, no message printed on console. seems mymethod not executed. wonder if give me suggestions. has driven me crazy.
many in advance.
the main thread of application exiting before other thread has chance process anything.
it work if add in simple sleep(1000)
statement anywhere before return 0
statement in main method.
Comments
Post a Comment