I have created two thread using and
static int counter (global variable) ;
-(void)ViewDidLoad {
[NSThread detachNewThreadSelector:@selector(handleTread:) toTarget:self withObject:nil];
[NSThread detachNewThreadSelector:@selector(handleTread:) toTarget:self withObject:nil];
}
and selector method is
-(void)handleTread:(NSThread*)sender {
counter =0; // Position-1
while (counter<9) {
counter =0; // Position-2
counter++;
}
NSLog(@"Counter=%d",counter);
}
So if I use counter at Position-1 it prints the result as counter=9. But I placed it at Position-2 it does not print? I have updated the question.