ios - NSRunloop in Thread -


i problem

here code

- (void)start{     [[nsrunloop currentrunloop] rununtildate:[nsdate distantfuture]]; }  - (void)nlog{     nslog(@"cool"); }   - (void)main{        thread = [[nsthread alloc] initwithtarget:self selector:@selector(start) object:nil];      [thread start];       [self performselector:@selector(nlog) onthread:thread withobject:nil waituntildone:no]; } 

when call

[self performselector:@selector(nlog) onthread:thread withobject:nil waituntildone:no]; 

the thread keeping running , can in thread later;

but if don't call it, thread exit @ once , can never use thread anything, why?

when start thread, if don't add source runloop, run loop return immediately. thread finished.

check out:

https://developer.apple.com/library/mac/documentation/cocoa/conceptual/multithreading/runloopmanagement/runloopmanagement.html#//apple_ref/doc/uid/10000057i-ch16-sw1


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -