Restricting thread count and Java concurrency

后端 未结 4 512
北海茫月
北海茫月 2021-01-14 06:51

I couldn\'t find an example of this specific case using the latest JAVA concurrent routines.

I plan to use threads to process items from an open queue w

4条回答
  •  孤独总比滥情好
    2021-01-14 07:30

    I had the same task: I used the BlockingQueue of the java.util.concurrent package. I created X worker threads which reads one action from the queue, processes it, and when ready take the next. This is simple, and it works fine.

    If you use X = 10 Worker threads, then your task is solved.

提交回复
热议问题