• Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread Saftey in JSF

 
Prem Khan
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was reading my book "JSF in action" by Kito mann, and it says you must watch out for session scope managed beans to be thread safe. Because other threads can manuipate the values in the same bean.

This doesnt make any sence to me, I have many users and iv never had any probblem with my session scope beans. I thought each User has there own instance of the bean.

Do you all use session scope beacuse I do
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'ts not that you have to be careful between users. What that means is that say you put a bean in the session and then the same user spawns several threads that can manipulate that session object. I say again, the same user. That is when you have to be careful.

With that being said, I rarely have a managed bean in session scope, though I'll have some objects in session that are used by various managed beans.
 
Prem Khan
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So how can one user spawn several threads ?

Is one user really one instance of a web browser ?
If thats the case I dont see how one user could spawn more than one
 
George Daswani
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Open a new Browser window (eq. Mozilla) which shares the session cookies

or the double submit problem.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shawn DeSarkar:
So how can one user spawn several threads ?

Is one user really one instance of a web browser ?
If thats the case I dont see how one user could spawn more than one


For the most part, you probably don't need to worry about thread safety and managed beans. It's just always a good idea to keep it in the back of your mind.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!