Use join() in thread

http://ideone.com/Kyy2KU