Re: [[NSNotificationCenter defaultCenter] postNotificationName] from a thread?
Re: [[NSNotificationCenter defaultCenter] postNotificationName] from a thread?
- Subject: Re: [[NSNotificationCenter defaultCenter] postNotificationName] from a thread?
- From: "Alastair J.Houghton" <email@hidden>
- Date: Sat, 1 Nov 2003 21:34:48 +0000
On Saturday, November 1, 2003, at 08:12 pm, Michael Rothwell wrote:
I'm writing an application that has several worker threads and uses
notifications. i'm worried about thread safety. In the worker threads,
I'm sending notifications back to the main thread like this:
[[NSNotificationCenter defaultCenter]
postNotificationName:@"UPnPDiscovery" object:self userInfo:d];
The main thread has registered for these notifications, and runs a
method, etc.
Should I be doing something to ensure thread safety?
I'm not certain whether NSNotificationCenter is thread safe, but it's
much easier to use NSObject's
-performSelectorOnMainThread:withObject:waitUntilDone: method, at least
at long as you don't mind a requirement of Mac OS X 10.2 or later.
For Mac OS X 10.1 and earlier, the usual technique seems to be to use
Distributed Objects to communicate with the main thread.
Kind regards,
Alastair.
_______________________________________________
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.