Grokking Multithreading and Concurrency for Coding Interviews
0% completed
Problem 12: Building H2O
Overview
The Building H2O problem is a classic synchronization challenge in concurrent programming. The main challenge is to ensure that two hydrogen threads and one oxygen thread are properly synchronized so that they can form a water molecule, H2O, without violating the given constraints. This scenario highlights the difficulty of coordinating multiple threads to achieve a specific sequence or grouping, making sure that they interleave in a way that leads to the correct result
.....
.....
.....
Like the course? Get enrolled and start learning!
Abhishek Yadav
· a year ago
Why is there the following lines in hydrogen method?
// Release the permit for the next Hydrogen
hSemaphore.release();
I am getting output as following
H H O H2O is generated!
H H O H2O is generated!
H H H O H2O is generated!
H H O H2O is generated!
H
Show 1 reply