Made use of Reentrant lock for synchronization