Re: Techniques for thread communication
Re: Techniques for thread communication
- Subject: Re: Techniques for thread communication
- From: Eric Scharff <email@hidden>
- Date: Mon, 8 Sep 2003 12:11:27 -0700 (PDT)
>
if the worker thread does not touch the result
>
thereafter, then you should have no problems.
Well, that's the thing. The getter lock is trying to avoid
1. worker calls setter
2. worker notifies sender on other thread
3. worker continues, calls setter
4. setter calls release on result but hasn't done assignment
yet
5. CONTEXT SWITCH
6. other thread calls result method, gets a now invalid thing
In Java (yeah, I know...) the way that I'd do this is with
syncronization of the instance methods, or
public synchronized void setResult(Result r) { result = r; }
public synchronized Result getResult() { return r; }
So my approach may be over-paranoid, but I don't think it's
broken. :)
-Eric
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
_______________________________________________
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.