Are LinkedBlockingQueue's insert and remove methods thread safe?

后端 未结 3 500
悲&欢浪女
悲&欢浪女 2020-12-03 00:34

I\'m using LinkedBlockingQueue between two different threads. One thread adds data via add, while the other thread receives data via take

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 00:50

    Simply Yes, its definitely thread safe otherwise it wouldn't have qualified as a candidate for storing element for ThreadPoolExecutor.

    Simply add and retrieve element without worrying about concurrency for BlockingQueue.

提交回复
热议问题