Problem statement:
Write a Java program that simulates a Water manufacturing factory. Your factory has infinitely capable Hydrogen and Oxygen producer units (independent units) provided free of charge by the government. Your pipeline (or consumer) should consume 2 atoms of Hydrogen and one atom of Oxygen to generate one molecule of Water. There are 3 things to note
- No wastage of Hydrogen or Oxygen
- The size of the pipes that take the output of both the Hydrogen and Oxygen producers is limited in length and can hold only 500 atoms at a time.
- The pipeline consumer that combines Hydrogen and Oxygen will take 5 seconds to generate 1 molecule of Water. Write a multi-threaded program to simulate the producer and consumer. Your factory’s output should be 10 molecules of Water per second
Can someone help me to code this problem!