I'm pretty new to threads in Java. I'm currently building a medium sized tool and for some reason I thought JavaBeans handled multiple threads... definitely not the case. I tested the tool on two difference machines at the same time and had them editing each others data -- not good.
So here's the extremely simplied layout of my code (ignore syntax errors):
Each listData must be entirely unique to each user (ie: a new listData should be created for each user) and the data should never be viewable by another user (it's not personal information or anything important).
How shoud I go about this? Any help would be much appreciated.
Bear Bibeault wrote:Are you perhaps storing it as an instance variable in a servlet? If so, that's the problem.
The only place I can think I might be "instantiating" it anywhere is in the faces-config.xml file.
I have the bean in there and call it from a number of different .jsp pages (ex: "Your data is: DataBean.viewData")
JSF beans are POJOs - generic JavaBeans. JavaBeans are simply Java classes treated as components, with certain conventions applied. If you want thread-safe, you have to provide it yourself as/where needed. The price of ultimate flexibility while retaining ultimate efficiency.
An IDE is no substitute for an Intelligent Developer.
Joined: Nov 24, 2009
Tim Holloway wrote:If you want thread-safe, you have to provide it yourself as/where needed.