hello2060
V2EX  ›  Java

Spring controller 的 handler 方法在处理多个请求的时候会在多个线程中运行吗?

  •  
  •   hello2060 · May 20, 2021 · 1401 views
    This topic created in 2015 days ago, the information mentioned may be changed or developed.

    一个单例的 controller

    @RequestMapping(value = {"/sync"}, method = RequestMethod.GET)
    void handleSync() {
         service.doxx()
    }
    
    

    如果同时有多个请求,会在多个线程中同时执行 handleSync() 还是会依次执行?感觉是前者?

    谢谢

    wangyu17455
    wangyu17455
    May 24, 2021 via Android
    1
    打印一下 threadname 不就知道了?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4392 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 07:19 · PVG 15:19 · LAX 23:19 · JFK 02:19
    ♥ Do have faith in what you're doing.