> Which part is correct?  The original code?

The original code was what I meant. However I was thinking of traditional
conditions & locks; NSConditionLock does operate at a higher level, and you
are right that there is no need for an unconditional lock. But really, I
don't see a need for a lock at all.

volatile int threadStatus = kConditionRun;


-(void)awakeFromNib
{
[NSThread detachNewThreadSelector:@selector(threadMethod:) toTarget:self
withObject:self];
}


- (void)threadMethod:(id)anObject
{
    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
    
    while (threadStatus == kConditionRun)
         [self doStuff];
        
    [pool release];

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


-(void)requestThreadExit
{
    threadStatus = kConditionThreadMustExit;
}


-(void) threadHasExited
{
    // clean up here
}


-- 
Scott Ribe
[EMAIL PROTECTED]
http://www.killerbytes.com/
(303) 722-0567 voice


_______________________________________________

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