Modified semaphore impl. Added monitor impl.