Synchronization solution using Semaphores and Mutex Locks