I have NetBSD on i386. I am using the GNU pthread library. When I run the following code, the same integer value is printed in both func1 and func2. The value 89 is printed in both functions.
Thanks.Code:#include <pthread.h> void func1(void *n) { int *a = (int *) n; printf("hello: %i\n", *a); } void func2(void *r) { int *b = (int *) r; printf("hello again: %i\n", *b); } void make_thread(pthread_t *thread, void (*func)(void *), int value) { printf("value: %i\n", value); pthread_create(thread, NULL, (void *) (func), &value); } int main() { int *retval; pthread_t thread1, thread2; make_thread(&thread1, &func1, 34); make_thread(&thread2, &func2, 89); pthread_join(thread1, (void **) &retval); pthread_join(thread2, (void **) &retval); return 0; }



LinkBack URL
About LinkBacks


