This problem reiterates the scenario from the Thread pool with a single thread section. We want a single producer and consumer that follow this scenario:
- An automatic system sends a request to the producer, saying, check this bulb and if it is ok then return it to me, otherwise tell me what went wrong with this bulb.
- The automatic system waits for the producer to check the bulb.
- When the automatic system receives the checked bulb, it is then passed further to the consumer (packer) and repeats the process.
- If a bulb has a defect, the producer throws an exception (DefectBulbException) and the automatic system will inspect the cause of the problem.
This scenario is depicted in the following diagram:
In order to ...