Because in your call to pthread_create
you actually call the function, and as it returns NULL
pthread_create
will fail. This will not properly initialize p1
and so will (probably) cause undefined behavior in the pthread_join
call.
To fix this pass the function pointer to the pthread_create
call, do not call it:
pthread_create(&p1, NULL, dostuff, NULL);
/* No parantehsis --------^^^^^^^ */
This should also teach you to check the return values of function calls, as pthread_create
will return non-zero on failure.