Concurrent and Blocking Queue in Java

后端 未结 6 2095
一生所求
一生所求 2020-12-12 18:42

I have the classic problem of a thread pushing events to the incoming queue of a second thread. Only this time, I am very interested about performance. What I want to achiev

6条回答
  •  孤街浪徒
    2020-12-12 19:10

    I would suggest you look at ThreadPoolExecutor newSingleThreadExecutor. It will handle keeping your tasks ordered for you, and if you submit Callables to your executor, you will be able to get the blocking behavior you are looking for as well.

提交回复
热议问题