hi all
i am using thread to print the value of x i though the value will be 10, but i found it 0????? Why , and haw can i adjust this thread to print x=10
i am waiting
i am using thread to print the value of x i though the value will be 10, but i found it 0????? Why , and haw can i adjust this thread to print x=10
Code:
#include <stdio.h> #include <pthread.h> void *thread1(void *param); int x; int main(int argc, char *argv[]) { pthread_t tid[1]; pthread_attr_t attr; pthread_attr_init(&attr); pthread_create(&tid[0],NULL,&thread1, NULL); pthread_join(tid[0],NULL); printf("x = %d\n", x); } void *thread1(void *param) { int x=10; pthread_exit(0); }
i am waiting
Comment