How is your mainThreadParm declared? If it's a file global scope non- pointer value, it could be getting optimized away.

Try declaring it static or volatile.

Also, if threads are changing mainThreadParm independently in non- atomic ways, you will want to put locks around the critical sections.

Joe K.



On Nov 21, 2008, at 6:24, John Love <[EMAIL PROTECTED]> wrote:

From the main Thread, I call:



[NSThread detachNewThreadSelector:@selector(bgThread:) toTarget:self withObject:nil];



- (void) bgThread:(NSConnection*)connection {

   NSAutoreleasePool *pool;

   pool = [[NSAutoreleasePool alloc] init];



   [self doCalculation];



[self performSelectorOnMainThread:@selector(endBgCalculation:) withObject:nil waitUntilDone:NO];



   [pool release];

}



- (void) endBgCalculation:(id)obj {

       // stuff

}



I believe this is fairly standard way to institute a background thread …



The problem centers on letting the background Thread look at a parm set in the main Thread and break out of the background Thread when the background Thread sees a certain value.



Specifically, my –doCalculation is just one great time-consuming for -loop that looks at mainThreadParm and breaks depending on the valu e of mainThreadParm.



I change mainThreadParm in the main Thread and I expect the background Thread to break when the background Thread sees a certain value of mainThreadParm.



The background thread sees the initial value of mainThreadParm, but does not break when the main Thread changes it.



This sounds so basic and fundamental that I really feel lacking on this subject.



John Love

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/joeman%40mac.com

This email sent to [EMAIL PROTECTED]
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to