main logic for multithreading task