Implemented semaphore.

fixes #16