java - Do @SessionScoped beans have concurrency issues? -
obviously, it's easy have multiple parallel requests accessing same @sessionscoped bean in web app context. correct in believing have explicitly control synchronization when accessing @sessionscoped bean within requests?
depends on mean by:
explicitly control synchronization when access @sessionscoped bean within requests
you right there may several threads accessing @sessionscoped
bean in parallel. have take care of thread safety. whether need explicitly control synchronization (or synchronize @ all) depends on how shared state used or modified different threads. if use classes java.util.concurrent
or java.util.concurrent.atomic
, may achieve perfect thread-safety without single synchronized
statement.
but yes, have take care of thread safety.
Comments
Post a Comment