Which ThreadPool in Java should I use?

前端 未结 5 1742
花落未央
花落未央 2021-02-06 06:00

There are a huge amount of tasks. Each task is belong to a single group. The requirement is each group of tasks should executed serially just like executed in a single thread an

5条回答
  •  春和景丽
    2021-02-06 06:41

    I would suggest to use task queues:

    • For every group of tasks You have create a queue and insert all tasks from that group into it.
    • Now all Your queues can be executed in parallel while the tasks inside one queue are executed serially.

    A quick google search suggests that the java api has no task / thread queues by itself. However there are many tutorials available on coding one. Everyone feel free to list good tutorials / implementations if You know some:

提交回复
热议问题