does the one thread kill the other in a iphone application( both thread are main thread)?

末鹿安然 提交于 2019-12-13 19:48:21

问题


HI guys,

==>in my application i have used three different thread code for one of them is here all thread are of same kind
==>i have defined two thread in appdelegate class ==>one in the root view controller ==>all the thread having different sleep time

My question is that does any thread may get killed by the other and the invocation time for one thread get affected by the other?

-(void)PostData
{
NSAutoreleasePool *apool = [[NSAutoreleasePool alloc] init];// we are responsible for the memory pool

while(TRUE)
{       
    [self performSelectorOnMainThread:@selector(PostAllthedata) 
                           withObject:nil 
                        waitUntilDone:YES]; 
    [NSThread sleepForTimeInterval:150]; 

}
[apool release];
}

-(void)PostAllthedata
{
PostSyncData *objPostSyncData=[[PostSyncData alloc]init];
[objPostSyncData release];    
}

回答1:


The Apple reference documents on the use of the method - (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait states

Multiple calls to this method from the same thread cause the corresponding selectors to be queued and performed in the same same order in which the calls were made.



来源:https://stackoverflow.com/questions/6120048/does-the-one-thread-kill-the-other-in-a-iphone-application-both-thread-are-main

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!