calculate time and distance between every two grids using multi-thread.