search

Home  >  Q&A  >  body text

java - 什么情况下需要使用多线程编程?

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

PHP中文网PHP中文网2811 days ago1085

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑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:

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

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

    reply
    0
  • Cancelreply