Are Spring Controllers Thread-Safe

前端 未结 4 1332
你的背包
你的背包 2021-02-05 18:21

I came upon this Controller example, and am wondering if it is thread-safe? I am wondering specifically about the gson instance variable.

import org.springframe         


        
4条回答
  •  醉梦人生
    2021-02-05 18:29

    Gson is definitely thread safe and was made this way back in 2008, so as long as your version is post that then it should be fine. I see no thread safety issues with your code. Although I would make the instance of Gson static.

提交回复
热议问题