mirror of
https://github.com/wu736139669/SmallGame_Cocos2dx.git
synced 2026-08-06 06:41:44 +00:00
31 lines
668 B
C++
31 lines
668 B
C++
/********************************************************************
|
|
created: 2014/04/01
|
|
filename: Thread.h
|
|
author: 王少培
|
|
purpose:
|
|
*********************************************************************/
|
|
|
|
#include "Thread.h"
|
|
#include "ccMacros.h"
|
|
#include "pthread.h"
|
|
|
|
void* threadFunc(void *arg)
|
|
{
|
|
CRunable* pThread = (CRunable*)arg;
|
|
pThread->run();
|
|
pthread_exit(NULL);
|
|
return 0;
|
|
}
|
|
|
|
void CRunable::start()
|
|
{
|
|
int nResult=0;
|
|
pthread_t thread;
|
|
if(nResult = pthread_create(&thread,NULL,threadFunc,this))
|
|
{
|
|
CCLOG("thread create failed: %d\n",nResult);
|
|
}
|
|
pthread_detach(thread);
|
|
//pthread_join(thread,NULL);
|
|
}
|