206. Callable and Future

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:

  1. 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.
  2. The automatic system waits for the producer to check the bulb.
  1. When the automatic system receives the checked bulb, it is then passed further to the consumer (packer) and repeats the process.
  2. 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 ...

Get Java Coding Problems now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.