multithreaded code works