1

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];    
}
NIKHIL
  • 2,719
  • 1
  • 26
  • 50

1 Answers1

0

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.

visakh7
  • 26,380
  • 8
  • 55
  • 69
  • actually in my application two thread are getting invoked after the sleep time but one is not getting invoke what can be the reason? – NIKHIL May 25 '11 at 06:43
  • 1
    If the two methods use the main thread at the same time, I think one of them is added to the queue – visakh7 May 25 '11 at 06:58
  • actually it is working as i have decrease the sleep time for the tread which was not getting invocked but i can not find the actual reason behind the thread was not getting invoked Thank u for answering – NIKHIL May 25 '11 at 07:02
  • @nikhil did u find that answer – Vijay-Apple-Dev.blogspot.com Jul 30 '11 at 14:54
  • @nikhil actually in my application two thread are getting invoked after the sleep time but one is not getting invoke what can be the reason? –this is my question.did u find the answer for this – Vijay-Apple-Dev.blogspot.com Aug 01 '11 at 07:57
  • @vijay :you need to give less invocation time for both thread and though it is not working please put you code snippet here or anywhere for to check – NIKHIL Aug 01 '11 at 13:25
  • @nikhil i didn't have any code about to paste.i had read ur problem .it got interesting me.so that i came to know about this from u.whats ur two thread timings.why did they not run before that.any reason.then please explain – Vijay-Apple-Dev.blogspot.com Aug 01 '11 at 13:29