i know that the following is how you are supposed to use NSCondition:
method 1:
[cocoaCondition lock];
while (someConditionIsTrue)
[cocoaCondition wait];
// Do real work here.
[cocoaCondition unlock];
method 2:
[cocoaCondition lock];
timeToDoWork++;
someConditionIsTrue = NO;
[cocoaCondition signal];
[cocoaCondition unlock];
all i want is to use a simple lock that can be locked and unlocked from different threads, so i understood i need to use NSCondition for that, and the apple doc says that checking for the condition is for extra cautious as well even if you don't logically use it (from apple doc: "To avoid problems caused by these spurious signals, you should always use a predicate in conjunction with your condition lock").
there is a dependency between the methods but it is in both ways, that means no one can do their body of work until the other method released the lock (which might get released on a third thread that was dispatched from the body of work of the method that locked it).
is it possible to wait on the condition from both methods and signal it at the end of both?
if i have 3 threads of method1 waiting simultaneously, in what order they will enter the body of work? i guess it is in the order in which they entered the waiting, am i correct?
First your code works well following another post here How does the NSCondition work?.
Second, do not call
that may be you want, or only use a NSXXLock.