java - 什么情况下需要使用多线程编程?
PHP中文网
PHP中文网 2017-04-17 17:55:54
0
1
1063

最近在研究多线程,对JMM,Executor框架,ThreadPoolExecutor都有一定的了解了,但是不清楚在什么业务场景下使用多线程编程会有优势?比如就一般的使用SpringMVC+Spring+Mybatis的从Controller到Service再到Dao的流程,哪里能用多线程处理?多线程处理以后就能提高系统的QPS吗?

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
巴扎黑

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:

  1. Do not block main thread tasks (background tasks)

  2. Concurrency, improve throughput (network multi-threading)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template