cocos2dx 多執行緒

2021-06-20 07:41:33 字數 542 閱讀 9968

2. 加標頭檔案 #include "pthread/pthread.h",直接上**

編譯出錯:fatal error c1083: 無法開啟包括檔案:「sched.h」: no such file or directory,

在pthread的相同目錄下有這個標頭檔案,在專案的屬性中加入這個標頭檔案的路徑就可以了

3. 如果要等待執行緒結束,可以加入下**

//等待執行緒結束

void * returnvaluefromthread;  

pthread_join(tid, &returnvaluefromthread);

4. ok,現在看完多執行緒後,再看看2dx自帶的network庫中,http的實現是使用多執行緒的,所以我們沒有必要在工程中自己再實現一遍。在專案中可以直接使用了

cocos2d x多執行緒操作

先頭檔案定義 void threada 再在.cpp檔案中新增 1.引入標頭檔案 include std thread t1 login threada,this 取login的位址 t1.detach 主線程和子執行緒互不影響 阻塞主線程 執行子執行緒完了後才執行主線程 cclog first t...

cocos2dx學習筆記(多執行緒)

多執行緒的實現 pthreadtest.h ifndef mtnotificationqueue h define mtnotificationqueue h include cocos2d.h include include pthread pthread.h using ns cc using ...

cocos2dx建立執行緒

為了防止程式假死,需要另起執行緒處理網路連線。好吧,那就從建立執行緒開始。這次我的環境是在mac下。在網上查閱和參考了很多資料,感謝這些無私奉獻的前輩們的努力。進入話題。標頭檔案 cpp view plain copy pthread t th socket 起這個名字本打算用在socket上的 i...