Pregunta de entrevista de AMD

c++ threads usage, semaphore, how to write thread safe code