How does Spring bean Handle concurrency

前端 未结 4 1695
栀梦
栀梦 2020-12-13 03:16

My web application uses Spring IOC. So all my spring beans will be singletons by default. In case if two requests try to access two different methods of a single class (for

4条回答
  •  伪装坚强ぢ
    2020-12-13 03:27

    If the bean is a singleton, then Spring will give you the same instance in any thread. It's up to you to make that bean thread-safe. Since it's a singleton, you'd be best off making that class stateless.

提交回复
热议问题