最近在研究多线程,对JMM,Executor框架,ThreadPoolExecutor都有一定的了解了,但是不清楚在什么业务场景下使用多线程编程会有优势?比如就一般的使用SpringMVC+Spring+Mybatis的从Controller到Service再到Dao的流程,哪里能用多线程处理?多线程处理以后就能提高系统的QPS吗?
巴扎黑2017-04-17 17:57:54
Java's servlet framework itself is multi-threaded, but this thread is started by the webserver for you, not by the user.
Generally speaking, if you handle network communication yourself, you need to do multi-threading processing yourself, or do background task processing, and you also need to do multi-threading processing yourself.
Main purpose of multithreading:
Do not block main thread tasks (background tasks)
Concurrency, improve throughput (network multi-threading)