Re: What's better a separate run loop or separate thread?
Re: What's better a separate run loop or separate thread?
- Subject: Re: What's better a separate run loop or separate thread?
- From: Fritz Anderson <email@hidden>
- Date: Sun, 11 Jul 2004 23:07:45 -0500
On 11 Jul 2004, at 9:28 PM, Ken Tozier wrote:
I don't know if it's just dumb luck on my part (I've only been using
threads for about two weeks) but I didn't notice any problems sending
notifications from threads. I just post them from inside the thread
and they magically arrive at their destination.
Maybe a little more magically than you mean: The problem is not whether
the NSNotifications get delivered. They'll get delivered. The problem
is that they are delivered on the same thread they were sent from.
This means the notification handler in your Class X can interrupt a
Class X method (on the main thread) in the middle, and make changes to
the instance variables. And then permit that main-thread method to
resume, with its data changed (one might say magically) out from under
it.
You see the problem. Unless you are very careful or lucky to avoid
collisions between the notifications and the main-thread business, pain
and sorrow will befall you.
-- F
_______________________________________________
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.