日期:2014-05-16 浏览次数:20761 次
#include <stdio.h> #include <pthread.h> void* start_thread(void *param) { char *str = (char *)param; printf("s:%s\n",__func__, str); return NULL; } pthread_t create_test_thread(char * buf) { pthread_t id =0; pthread_create(&id, NULL, start_thread,buf); return id; } int main(void) { void *ret = NULL; char buf[] ="helloword"; pthread_t id = create_test_thread(buf); pthread_join(id,&ret); return 0; }
#include <stdio.h> #include <pthread.h> void* start_thread(void *param) { char *str = (char *)param; printf("s:%s\n",__func__, str); return NULL; } pthread_t create_test_thread() { pthread_t id =0; char buf[] ="hello world"; pthread_create(&id, NULL, start_thread,buf); return id; } int main(void) { void *ret = NULL; pthread_t id = create_test_thread(); pthread_join(id,&ret); return 0; }
#include <stdio.h> #include <pthread.h> void* start_thread(void *param) { char *str = (char *)param; printf("s:%s\n",__func__, str); return NULL; } pthread_t create_test_thread(char * buf) { pthread_t id =0; pthread_create(&id, NULL, start_thread,buf); return id; } int main(void) { void *ret = NULL; char buf[] ="helloword"; pthread_t id = create_test_thread(buf); return 0; }