I am reading some servlet text regarding scope of attributes in Java servlet. In the text, the author wrote:
“Session attributes are officially not thread safe.“
This confused me because I thought that one user only has a specific session, no one can access of the others. If so, session attributes are thread safe. Or am I misunderstanding something??
Well, if that was the case, session attributes need not be thread-safe. That is different from saying they are thread-safe.
The lack of thread safety might be a problem if you have more than one thread handling the same user’s session at the same time. Maybe some parallel executions that you spawned from the main request worker thread. Or the same user accessing the server more than once (such as loading five frames at the same time).