Conform to coding style and add a semaphore.