大部分内容为博友贡献,因此注明转载。
#include <thread>
int pthread_create(pthread_t * __restrict,//线程标示
const pthread_attr_t * __restrict,//创建线程的参数
void *(*)(void *),//入口函数的指针
void * __restrict);//传递给线程的数据
.h
pthread_t t1,t2;
static void* t1_run(void* r);
static void* t2_run(void* r);
.cpp
pthread_t t1;
pthread_create(&t1,NULL,action,NULL);
注意:
OpenGL规范,不允许在子线程中生成texture,所以可以先把png图片在主线程种添加到TextureCache中缓存,在子线程中再把plist添加到SpriteFrameCache中