[問題] pthread_create成功但function沒跑
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Win7上用VirtualBox跑的Ubuntu 13.10
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
pthread.h
問題(Question):
#include<pthread.h>
...
void* function( void* );
#define thread_num 4
int main(){
pthread_t *pt;
unsigned long long num;
pt = new pthread_t[thread_num];
for( int z = 0 ; z < thread_num ; z++ )
pthread_create( &pt[z] , NULL , function , (void*) num );
※我試過在function前面+"&"也不行
...
}
void* function( void* t ){
printf("QQ\n");
unsigned long long times = (unsigned long long) t;
...
}
pthread_create的回傳值是0
但是印不出"QQ"
所以thread有create但是沒有跑進function
請問為什麼OTL
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.94.144
→
10/30 00:06, , 1F
10/30 00:06, 1F
→
10/30 00:14, , 2F
10/30 00:14, 2F
→
10/30 01:01, , 3F
10/30 01:01, 3F
推
10/30 23:19, , 4F
10/30 23:19, 4F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):