I'm newbie with this so forgive me with any mistakes...
My situation:
- (id)initWith... //Some arguments
There's an initialization method that returns an object. It does a lot of work to set its instance variables with the values of the arguments. To maximize performance I divide the job in two threads. One thread sets a set of related variables and the other thread another bunch of them.
- (id)initWith:arguments {
self = [super init];
if (self) {
[NSThread detachNewThreadSelector:@selector(setFirstSetOfVariables:) toTarget:self withObject:argObject];
[self setSecondSetOfVariables:arguments];
//Check if the thread finished its work and return the value
return self;
}
To make it easy think both sets of vars that the method has to set don't have any relationship. Then my question is: how do I check if the first thread finished? I could create a BOOL var but I'd have to create a loop to check. I could also call a method to say it's ready. But as I don't know a lot of it, I don't know wether a method invoked inside a thread would be run in the main thread or in the other. Sorry. Thank you for any info.