On 8 Jan 2009, at 12:28 pm, John Cassington wrote:

After testing, the dictionary concept works perfectly! Thanks!

With regard to the originating thread retaining a reference to the
dictionary, is there a way for the original thread to know when
processing has completed on the secondary thread?

I would like my method to be run on a separate thread, but be able to
return a value to the caller in the normal fashion.


Threads are able to access the same data, including the originating object. Indeed, it is likely to be running as a method of the originating object. So just set up a callback that you call when done. Using -performSelectorOnMainThread:withObject:waitUntilDone: is useful to make sure that you bounce the completion functionality back to the main thread and not run it from your secondary thread.

There seems to be a misconception about threads that they are totally sealed off from the rest of your program. That's not the case - in fact, therein lies the trickiness of threads - you need to be mindful about the possibility of the same data being accessed from different threads.

--Graham


_______________________________________________

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 arch...@mail-archive.com

Reply via email to