solutions to 'The Little Book of Semaphores' in java