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");
}
}
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");
}
}
相关文章推荐
- cocos2d-x,Ios里面多线程的用法
- iOS中通过GCD实现多线程用法
- iOS开发中的多线程的GCD用法
- iOS多线程_06_GCD其它用法
- iOS多线程开发之NSOperation用法总结-----经典
- iOS开发多线程-GCD的常见用法
- iOS 多线程 GCD(滚床单) 的高级用法
- 浅谈IOS中的多线程及其用法示例
- IOS学习之多线程(8)--GCD的常见用法
- iOS多线程GCD简单用法
- cocos2d-x中CCArray里面CCARRAY_FOREACH的用法
- ios多线程-GCD基本用法
- iOS多线程之8.NSOPeration的其他用法
- ios多线程 -- GCD 常见用法
- iOS 之多线程用法示例
- WairForSingleObject用法,在多线程里面通过事件通知
- iOS多线程管理-Thread,NSOperation,GCD的简单用法
- cocos2d-x中CCArray里面CCARRAY_FOREACH的用法
- cocos2d-x中CCArray里面CCARRAY_FOREACH的用法
- ios中的多线程的用法总结