hello2060
V2EX  ›  Java

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

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

    一个单例的 controller

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

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

    谢谢

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