Re: Why RunLoop?
Re: Why RunLoop?
- Subject: Re: Why RunLoop?
- From: Uli Kusterer <email@hidden>
- Date: Fri, 20 May 2011 10:25:41 +0200
On 17.05.2011, at 21:12, Wim Lewis wrote:
> On 17 May 2011, at 9:54 AM, Bing Li wrote:
>> But I noticed that Cocoa threading provides wait/pulse-like synchronization
>> techniques, such as Condition. I believe these techniques can be used to
>> control a thread which has a while-true loop. So I think RunLoop can be
>> replaced. Do you think so?
>
> In a thread that you "own", you can certainly write in a style that does not use a run loop, and this is sometimes the best approach. However, if you are writing a GUI application, the main thread must be run loop based for the application to work, because Cocoa relies on the run loop.
It's not just the main thread. Many asynchronous Cocoa APIs actually need a run loop to correctly function. You don't need a run loop to do some number crunching in basic C, but classes like NSURLConnection may not behave as expected if your thread has no run loop.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.lookandfeelcast.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden