2
我用c寫了一些代碼,使用pthread(我首先在eclipse IDE中配置了鏈接器和編譯器)。遠程函數與pthread
#include <pthread.h>
#include "starter.h"
#include "UI.h"
Page* MM;
Page* Disk;
PCB* all_pcb_array;
void* display_prompt(void *id){
printf("Hello111\n");
return NULL;
}
int main(int argc, char** argv) {
printf("Hello\n");
pthread_t *thread = (pthread_t*) malloc (sizeof(pthread_t));
pthread_create(thread, NULL, display_prompt, NULL);
printf("Hello\n");
return 1;
}
工作正常。但是,當我將display_prompt移至UI.h 時,不會輸出「Hello111」輸出。
有人知道如何解決這個問題嗎? Elad
我覺得沒有明確返回0,而是有EXIT_SUCCESS。 – evilpie 2010-05-22 10:07:08
是的。並不是說它的價值永遠不會改變,但它更加明確。 – Thomas 2010-05-22 21:00:34
謝謝。 我的問題是不同的:當所有的函數都在一個文件時,它工作正常。當將display_prompt()移動到其他文件時,它不起作用。 我添加了thread_join,但現在在同一個文件中的display_prompt()不起作用時。有沒有一種特殊的方法來在Eclipse中進行調試? – 2010-05-23 11:53:22