Re: Threads, messages and blocking
Re: Threads, messages and blocking
- Subject: Re: Threads, messages and blocking
- From: Dustin Voss <email@hidden>
- Date: Fri, 30 May 2003 00:32:47 -0700
On Thursday, May 29, 2003, at 03:26 PM, 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?
Try the InterThreadMessaging library,
<
http://www.cocoadev.com/index.pl?InterThreadMessaging>. I can attest
that it works well.
You might hear a suggestion to use the ThreadWorker class, but that
needs a separate thread for each task. Still, Mach threads are cheap
from what I've heard, and ThreadWorker seems very easy to use. See
<
http://www.cocoadev.com/index.pl?ThreadWorker>.
_______________________________________________
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.