Re: Thread Question
Re: Thread Question
- Subject: Re: Thread Question
- From: Bob Ippolito <email@hidden>
- Date: Tue, 27 Apr 2004 22:11:24 -0400
On Apr 27, 2004, at 9:43 PM, Dave Keck wrote:
after following along with these posts on NSTimers and NSThreads, I
remembered a question I've had for awhile now...
Say I have a thread, myThread, and I also have the main thread,
mainThread. I also have a method, myMethod:
Question 1: Is it OK to call myMethod from myThread? Is myMethod
within the "scope" of myMethod (assuming all this code is in the same
class)?
Question 2: If Question #1 is "yes": is it safe to call myMethod from
both mainThread and myThread, possibly at the same time (if, say,
mainThread and myThread both had loops that called myMethod)? (Would I
have to use NSLocks for methods too?)
Question 3: If it is OK to call myMethod from both mainThread and
myThread: what happens when I do? Does it call the method by the same
address if I were to call it from mainThread and myThread, or does
each thread have its own "copy" of each method that it calls?
Answer [1-3]: It depends. It's possible to write code that fits yes or
no to any of these questions.
-bob
_______________________________________________
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.