improved pthread.c