new Semaphore class, untested