• 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: Multiprocessor Support
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiprocessor Support


  • Subject: Re: Multiprocessor Support
  • From: Nick Zitzmann <email@hidden>
  • Date: Tue, 12 Aug 2003 19:23:44 -0700

On Tuesday, August 12, 2003, at 11:49 AM, Lance Pysher wrote:

Several of my objects would generate several threads during the init process. How do people make the thread wait until the tasksare done.

Well, you can do this with NSConditionLock... Try something like this: (warning - written in Mail, untested, use at your own risk, etc.)

enum
{
threadNotDone,
threadDone
};

- (void)init
{
// do your usual init stuff, then...
someLock = [[NSConditionLock alloc] initWithCondition:threadNotDone];

[NSThread detachNewThreadSelector:@selector(someMethod:) toTarget:self withObject:blah];
[someLock lockWhenCondition:threadDone]; // freeze here until someMethod: is done
[someLock unlock];
// etc...
}

- (void)someMethod:(id)blah
{
// do stuff...
[someLock lock];
[someLock unlockWithCondition:threadDone]; // get the main thread moving again
}

Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page: http://seiryu.home.comcast.net/

"I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." - Bjarne Stroustrup
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
  • Follow-Ups:
    • Re: Multiprocessor Support
      • From: Nick Zitzmann <email@hidden>
    • Re: Multiprocessor Support
      • From: Lance Pysher <email@hidden>
References: 
 >Multiprocessor Support (From: Lance Pysher <email@hidden>)

  • Prev by Date: [ANN] Cocoa Browser + WebKit patch available
  • Next by Date: Tons of fun w/NSComboBox
  • Previous by thread: Multiprocessor Support
  • Next by thread: Re: Multiprocessor Support
  • Index(es):
    • Date
    • Thread