Re: passing data to threads
Re: passing data to threads
- Subject: Re: passing data to threads
- From: "Philip Q" <email@hidden>
- Date: Wed, 20 Dec 2006 19:31:14 +1300
On 20/12/06, William Irving Zumwalt <email@hidden> wrote:
I'm trying to implement threads and not sure how to pass the *config object
into a newly created thread. I'm using an example from the book Cocoa
Programming.
Anyone have ideas?
There are a few ways to approach this:
- You can use a shared ivar in the NetworkObject that you set and
check/wait on in the thread. This is by far the easiest way, but you
have to be careful and implement good locking on the ivar to avoid any
nasty thread-safety issues.
- You can send the object as part of a method call on the thread. You
can call methods on the thread by using an NSPort. This involves a bit
more setup, but check out ThreadMessage
<http://www.blackholemedia.com/code/> for a simple library that does
it/for some sample code.
-Phil
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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