Re: Thread crashing problem
Re: Thread crashing problem
- Subject: Re: Thread crashing problem
- From: "Kyle Sluder" <email@hidden>
- Date: Mon, 22 Dec 2008 11:10:07 -0500
On Mon, Dec 22, 2008 at 10:42 AM, Ken Tozier <email@hidden> wrote:
> "You should not use this class to implement a recursive lock. Calling the
> lock method twice on the same thread will lock up your thread permanently.
> Use the NSRecursiveLock class to implement recursive locks instead."
It says "lock", not "tryLock."
> Given that, could you give a really simple example of how to coordinate
> access between the three methods? @synchronized may be the way to go but it
> doesn't explain how one method could determine busy status and wait for an
> opening before doing its thing.
Simply put, when you're doing threading, you don't "determine"
anything. You use the synchronization primitives you have to control
your code. Any attempt you make to "determine" which thread should
execute will either be 1) useless because the synchronization
primitives are already controlling thread execution; or 2) incorrect
because you've introduced the very race conditions you're trying to
avoid.
--Kyle Sluder
_______________________________________________
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