Final Modifications and Using Mutex and Unique locks to synchronize threads