When should I use SynchronousQueue

前端 未结 6 790
無奈伤痛
無奈伤痛 2020-12-22 17:46
new SynchronousQueue()
new LinkedBlockingQueue(1)

What is the difference? When I should use SynchronousQueue against LinkedBlock

6条回答
  •  星月不相逢
    2020-12-22 18:17

    One reason to use SynchronousQueue is to improve application performance. If you must have a hand-off between threads, you will need some synchronization object. If you can satisfy the conditions required for its use, SynchronousQueue is the fastest synchronization object I have found. Others agree. See: Implementation of BlockingQueue: What are the differences between SynchronousQueue and LinkedBlockingQueue

提交回复
热议问题