Spring: Singleton/session scopes and concurrency

前端 未结 3 805
無奈伤痛
無奈伤痛 2021-02-02 01:48

Does singleton/session scopes of Spring beans require that access to all its fields must be synchronized? Say through \"synchronized\" keyword or using some classes from package

3条回答
  •  你的背包
    2021-02-02 02:36

    Only the user for that session can access this class, but ArrayList is not thread-safe, as seen in this discussion: http://forums.sun.com/thread.jspa?threadID=5355402

    You need to ensure that your class is fully thread-safe as SessionScoped will just ensure that it is only used by each session, so one session can't access it.

    You may want to look at the comments in this discussion for more info: http://wheelersoftware.com/articles/spring-session-scoped-beans.html

提交回复
热议问题