This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes Concurrency in JSF managed bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Concurrency in JSF managed bean" Watch "Concurrency in JSF managed bean" New topic
Author

Concurrency in JSF managed bean

Joshua Antony
Ranch Hand

Joined: Jun 05, 2006
Posts: 254
Hi All,

We have several JSF managed beans in our applications which consist of many instance variables.

Are the beans thread safe, I mean if 5 jsf uses same bean then will it be 5 bean object created or just a single object and 5 different threads?

Regards,
Joshua


SCJP,SCWCD, Into ATG now!
Piotr Swiecicki
Greenhorn

Joined: Nov 16, 2006
Posts: 17
They are thread safe unless you not bind them to the session/application scope. In that case it may happen that 2 requests will operate on the same bean instance.
Joshua Antony
Ranch Hand

Joined: Jun 05, 2006
Posts: 254
Forgot to mention, all the beans in our application are session scoped.

I guess 2 request will operate on the same bean instance only if both request are from the same client, right?

Regards,
Joshua
Bob Good
Ranch Hand

Joined: Jan 09, 2008
Posts: 86
One thing can happen in Internet Explorer if a user chooses 'open in new window' is that the new windows gets the same session id as the original windows. These windows would then be going after the same managed beans.
There are many situations where this can wreak havoc unless you handle it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Concurrency in JSF managed bean
 
Similar Threads
Design flow question ?
Injection problem - not quite sure if this is something i should be using injection for
How to get session scope backbean
can I get the request object in managed bean?
JSF bean container