Multi-threaded map function