multithreading implemented in a proper way