add multi thread to compute distance