First attempt on pthreads version