On May 17, 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?
Sure -- if you want to re-invent the wheel and ensure that you don't make a wheel as round as the one that is provided by the frameworks. The run loops are implemented very efficiently; they use various kernel primitives to ensure that a wide variety of event sources can be used without needing polling internally. Similarly, GCD's dispatch sources allow for similar event response patterns while using queues. All of these will be preferable to spawning a thread and parking it. A parked thread still uses resources; it still consumes kernel resources (kernel has to maintain the execution context and stack and, when it runs, schedule it) and it consumes user space memory. b.bum _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com