• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Thread Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Thread Question


  • Subject: Thread Question
  • From: Dave Keck <email@hidden>
  • Date: Tue, 27 Apr 2004 21:43:35 -0400

Hey,

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?

Thank you very much for any insight!

Dave
_______________________________________________
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.


  • Follow-Ups:
    • Re: Thread Question
      • From: Brian Bergstrand <email@hidden>
    • Re: Thread Question
      • From: Bob Ippolito <email@hidden>
  • Prev by Date: Re: NSStreamEventHasBytesAvailable not getting thrown
  • Next by Date: Re: NSString format specifiers (was: Is Concatenation that complex?)
  • Previous by thread: Re: Reading Java files
  • Next by thread: Re: Thread Question
  • Index(es):
    • Date
    • Thread