hello2060
V2EX  ›  Java

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

  •  
  •   hello2060 · May 20, 2021 · 1182 views
    This topic created in 1882 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   ·   5507 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 48ms · UTC 06:36 · PVG 14:36 · LAX 23:36 · JFK 02:36
    ♥ Do have faith in what you're doing.