thread implementation of map