RollerSession有以下代码:
public static RollerSession getRollerSession(HttpServletRequest request) {
RollerSession rollerSession = null;
HttpSession session = request.getSession(false);
if (session != null) {
rollerSession = (RollerSession)session.getAttribute(ROLLER_SESSION);
if (rollerSession == null) {
// HttpSession with no RollerSession?
// Must be a session that was de-serialized from a previous run.
rollerSession = new RollerSession();
session.setAttribute(ROLLER_SESSION, rollerSession);
}
....
我是并发问题的新手。这里似乎存在原子性违规,两个不同的线程可能同时更新 setAttribute。是对的吗?鉴于会话是从请求中获取的,会话是否可以由两个线程共享?