How to avoid race condition with JSF and managed beans?

Discussions

Web tier: servlets, JSP, Web frameworks: How to avoid race condition with JSF and managed beans?

  1. Hi! I have an application where two thread sometimes tries to access the same bean at the same time. The bean is managed and in session scope. This is what happens: A: Access bean. Does not exist in session, created by jsf. B: Access bean. Does not exist in session, created by jsf. A: Bean added to session. A: Put some data in the bean. B: Bean added to session overwriting bean created by A! B: Read some data from the bean. C (in next call from client): Want to get the data put in the bean by A but instead gets bean created by B and the data is null! How do I avoid this? Creation and session-putting is handled by the framework and so can not be synchronized (or can it)?
  2. Why would you want to avoid Race Condition? He's cool.