Implementing Producer consumer pattern

后端 未结 3 1926
夕颜
夕颜 2021-01-06 16:29

I am trying to write a mail utility that places mails in a queue, and it is later consumed by a consumer thread.

I am trying to implement a typical producer-consumer

3条回答
  •  臣服心动
    2021-01-06 17:22

    1. You must use loops so that your producer/consumer code is executed more than once.

    2. Your threads do not communicate with each other. Currently you have only two threads being executed. Look at the example in the BlockingQueue javadoc of how to do it.

提交回复
热议问题