您的位置:首页 > 移动开发 > Cocos引擎

cocos2d-x,Ios里面多线程的用法

2012-02-06 17:10 253 查看
代码如下:

void *threadProcessFunction(void *ptr)

{

printf("enter thread\n");

//do thread thing

//exit thread

printf("exit thread\n");

return NULL;

}

void startRequestThread()

{

// Create the thread using POSIX routines.

pthread_attr_t attr;

pthread_t posixThreadID;

int returnVal;

returnVal = pthread_attr_init(&attr);

assert(!returnVal);

returnVal = pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);

assert(!returnVal);

int threadError = 0;

threadError = pthread_create(&posixThreadID, &attr, &threadProcessFunction, (void*)value);

returnVal = pthread_attr_destroy(&attr);

assert(!returnVal);

if (threadError != 0)

{

printf("create thread error");

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: