This question evaluates concurrency and synchronization skills, including thread coordination, use of locks/semaphores/condition variables, and reasoning about safety and liveness properties in concurrent systems.
You are given two kinds of threads that repeatedly call the following functions:
Each function receives a callable action:
Design synchronization so that the program outputs a valid sequence of water molecules. For every molecule, exactly two H actions and one O action must be released together (i.e., the three actions for a molecule proceed as a group; groups do not interleave).
Login required