Second Version: One code for 3 threads