Code for mapping using threads
Merge from wordMap