Removed some gibberish
Improved semaphore locking by giving away the thread's timeslice