Re: [Q] NSThreads and UI
Re: [Q] NSThreads and UI
- Subject: Re: [Q] NSThreads and UI
- From: Shawn Erickson <email@hidden>
- Date: Fri, 20 Sep 2002 08:39:39 -0700
On Thursday, September 19, 2002, at 09:18 PM, Mark de Jong wrote:
Hi!
I've got a task that gets time-consuming and I'd like to do it in its
own thread.
The main issue I'm having is that even though a method is running in
its own thread, the UI is really bogged down and doesn't function at
all.
I came across the "Threadworker" helper written by Robert Harder which
was supposed to make this better. In it, he starts the thread and
then, from within the thread, he uses NSTimer to launch the actual
routine that's supposed to run in the thread.
Unfortunately, the code does not explain why he does this. Is there an
explanation somewhere that describes why this is done?
Not sure of the setup of Threadworker... it could be acting like a
worker thread pool or a plain work thread that sits around waiting for
someone to hand it something to do. It could also be an attempt to
stager process in the thread, which doesn't seem like the best thing to
be doing or the best way to achieve that goal.
I tried mimicking this behavior in my own thread code and the UI is
still basically stopped until the thread finishes.
What does your code look like?
Are you sure the work you are doing is being run by the work thread you
create and this thread doesn't block your main threads run loop/event
loop?
What type of processing are you doing, is it requiring heavy swapping
and/or sucking a lot of RAM? (you create autorelease pools in your
secondary thread, correct?)
I thought the threads were preemptive and that all the threads were
given equal time to process. I'm obviously missing something here.
Yes, things are preemptively scheduled but all thread do not have to
have equal priority even threads in the same process. You should be
able to drop the priority of your worker thread but I don't think that
should be needed (I haven't needed to do this is similar situations).
-Shawn
_______________________________________________
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.