我ThreadData結構:解引用一個結構內的陣列正在使用ptread_create
typedef struct threadData {
pthread_t *ths;
} threadData;
其中*是部份的pthread_t
陣列。
現在,我創建的動作,使用下面的函數,它創建的部份[1]
void *rootThread(threadData *d) {
pthread_t *b = (*d).ths;
pthread_create(*(b+1),NULL,someRandomFunction,NULL);
}
但是,這似乎並沒有工作,一個新的線程的線程。
我不確定我是否很好地解引用了pthread_t元素。請幫忙!
謝謝,:)。
你如何分配你的struct treadData?目前,您似乎創建線程數據的成員ths只是作爲一個指針,沒有爲它分配內存。 rootThread獲取一個指向threadData的指針。所以使用它作爲pthread * b = d->進一步的pthread_create需要一個指向pthread_t的指針,因此不要使其不合適。 – hetepeperfan 2013-02-24 22:36:07