cocoanslock

NSLock - should just block when locking a locked lock?


I have a loop which starts with a

[lock lock];

because in the body of the loop I am creating another thread which needs to finish before the loop runs again. (The other thread will unlock it when finished).

However on the second loop I get the following error:

2011-02-02 07:15:05.032 BLA[21915:a0f] *** -[NSLock lock]: deadlock (<NSLock: 0x100401f30> '(null)')
2011-02-02 07:15:05.032 BLA[21915:a0f] *** Break on _NSLockError() to debug.

The "lock" documentation states the following:

Abstract: Attempts to acquire a lock, blocking a thread’s execution until the lock can be acquired. (required)

which makes me think it would just block until the lock could be acquired?


Solution

  • Sounds like two problems: