What are the advantages of Blocking Queue in Java?

后端 未结 2 2020
臣服心动
臣服心动 2020-12-31 04:18

I am working on a project that uses a queue that keeps information about the messages that need to be sent to remote hosts. In that case one thread is responsible for puttin

2条回答
  •  情歌与酒
    2020-12-31 04:41

    They key thing you eliminate with the blocking queue is 'polling'. This is where you say

    In that case the 2nd thread needs to check the queue for the information periodically.

    This can be very inefficient - using much unnecessary CPU time. It can also introduce unneeded latencies.

提交回复
热议问题