Thread-safe circular buffer in Java

后端 未结 8 1730
不知归路
不知归路 2020-12-08 05:23

Consider a few web server instances running in parallel. Each server holds a reference to a single shared \"Status keeper\", whose role is keeping the last N re

8条回答
  •  伪装坚强ぢ
    2020-12-08 05:37

    Also have a look at java.util.concurrent.

    Blocking queues will block until there is something to consume or (optionally) space to produce:

    http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/BlockingQueue.html

    Concurrent linked queue is non-blocking and uses a slick algorithm that allows a producer and consumer to be active concurrently:

    http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/ConcurrentLinkedQueue.html

提交回复
热议问题