multi threaded version of djikstras