0

这是防止多个线程访问函数 MyTaskF 的正确方法吗?

.h 文件:

@interface MyInterface  : NSObject {

//... some other stuff here

}

.m 文件:

static NSLock *mytaskMutex;

static MyInterface *MyInterfaceSingleton;

int MyTaskF(int iVar)
{

    [mytaskMutex lock];

    //do stuff in here

    [mytaskMutex unlock];

    return 0;
}
4

0 回答 0