What is the use of a Thread pool in Java?

前端 未结 7 1970
醉梦人生
醉梦人生 2020-12-04 09:02

What is the use of a Thread pool? Is there a good real world example?

7条回答
  •  悲哀的现实
    2020-12-04 09:33

    You may assume Threads to be actual workers and Thread Pools to be group of workers. You may create multiple groups for various reasons like priority, purpose, etc. So, while one pool may be for general purpose tasks like background schedules, email broadcasting, etc. there might be a transaction processing pool to simultaneously process multiple transactions. In case of an Executor Service, I am sure you would not like to delay the transactional jobs to be completed after other non-critical activities like broadcasting confirmation emails or database maintenance activities are not completed. You may segregate them into pools and maintain them independently. That's a very simplistic answer without getting into technical jargons. Regards, KT

提交回复
热议问题