Added multi-threading and Semaphores