• 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
Re: Threads, messages and blocking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threads, messages and blocking


  • Subject: Re: Threads, messages and blocking
  • From: Drew McCormack <email@hidden>
  • Date: Fri, 30 May 2003 11:09:56 +0200

On Friday, May 30, 2003, at 12:26 AM, Sean Harding wrote:

On Thu May 29 at 11:07:57 PM, Tom Sutcliffe wrote:

Short answer: in the second thread, you probably want to call
NSObject's performSelectorOnMainThread.

Long answer: It depends on what work you want thread 1 to be able to do
while thread 2 is running, and what thread 1 actually is. If it is the
main application thread, then you use performSelectorOnMainThread,
which is Cocoa's way of doing callbacks. Thread 1 can continue to run

Yes, thread 1 is the main application thread. performSelectorOnMainThread
looks like it could help. But I'm not sure it will completely solve the
problem. Sometimes I'll have thread 2 idle while thread 1 does unrelated
stuff, and then thread 1 will need it to do something.
performSelectorOnMainThread only allows communication thread 2->thread 1
(main thread), it appears. So it doesn't give me any way to have the main
thread send thread 2 another "go to work" message. Am I misunderstanding the
suggestion?
The way it is often done is that a second thread is split off with the "detachThread..." method, and that this is the "go to work" method. You split off a new thread each time you have some work, and it calls back with the performSelectorOnMainThread when it is finished.

I guess having a different thread for each piece of work could be expensive if your units of work are short, but if they are so short, you probably don't need multithreading.

----------------------------------
Dr. Drew McCormack
Trade Strategist (www.trade-strategist.com)
Stock Market strategy design platform for Mac OS X.
_______________________________________________
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: Threads, messages and blocking
      • From: Drew McCormack <email@hidden>
References: 
 >Re: Threads, messages and blocking (From: Sean Harding <email@hidden>)

  • Prev by Date: Re: simple float/double question
  • Next by Date: Re: Threads, messages and blocking
  • Previous by thread: Re: Threads, messages and blocking
  • Next by thread: Re: Threads, messages and blocking
  • Index(es):
    • Date
    • Thread