multithreaded the counting