optimized memory utilization of Pthreads version