Spawning thread in main