Code for measuring execution time of each thread