Which Java blocking queue is most efficient for single-producer single-consumer scenarios

后端 未结 7 2149
野的像风
野的像风 2020-12-23 16:32

I\'m working on a standard Java system with critical timing requirements for my producers (1/100s of ms matters).

I have a producer placing stuff in a blocking queu

7条回答
  •  轮回少年
    2020-12-23 17:16

    ArrayBlockingQueue will probably be faster as you do not need to create link nodes on insertion. Note, however, that ArrayBlockingQueue is of a fixed length, if you want your queue to grow arbitrarily large (at least to Integer.MAX_INT) you will have to use a LinkedBlockingQueue (unless you want to allocate an array of Integer.MAX_INT elements).

提交回复
热议问题