Updated threading, mutex, semaphores and polling