Multithreaded implementation