How to use NSLock in a function?

411 views Asked by At

Is this the correct method to prevent more than one thread to access the function MyTaskF?

.h file:

@interface MyInterface  : NSObject {

//... some other stuff here

}

.m file:

static NSLock *mytaskMutex;

static MyInterface *MyInterfaceSingleton;

int MyTaskF(int iVar)
{

    [mytaskMutex lock];

    //do stuff in here

    [mytaskMutex unlock];

    return 0;
}
0

There are 0 answers