Working mutithreading and synchronization