Apply multithreading to facilitate multicore usage