• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Thread deadlock?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thread deadlock?


  • Subject: Re: Thread deadlock?
  • From: Scott Ribe <email@hidden>
  • Date: Mon, 11 Aug 2008 14:21:37 -0600
  • Thread-topic: Thread deadlock?

> 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@hidden
http://www.killerbytes.com/
(303) 722-0567 voice


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Thread deadlock?
      • From: Trygve Inda <email@hidden>
    • Re: Thread deadlock?
      • From: Trygve Inda <email@hidden>
References: 
 >Re: Thread deadlock? (From: Peter Duniho <email@hidden>)

  • Prev by Date: Re: Newbie Question on "self"
  • Next by Date: Re: Use of AppKit in command-line app on headless node
  • Previous by thread: Re: Thread deadlock?
  • Next by thread: Re: Thread deadlock?
  • Index(es):
    • Date
    • Thread