[jboss-user] [Microcontainer] - Re: POJO thread safety

alesj do-not-reply at jboss.com
Wed Feb 20 11:06:15 EST 2008


"david.lloyd at jboss.com" wrote : If I have a POJO that (for example) represents a service that has a few properties that will be injected, what thread-safety precautions must I take?  
  | 
It depends on your service. :-)
See what we do below.

"david.lloyd at jboss.com" wrote : 
  | Will the POJO be instantiated, configured, and started/stopped all from the same thread?
  | 
Nope or it depends. ;-)
e.g. first thread will install the pojo, but it has some dependencies that don't allow it to be configured (missing injection)
Then that missing injection bean gets installed (via HDScanner thread that picked up -beans.xml), which pushes our first bean fwd.
So threads differ.

"david.lloyd at jboss.com" wrote : 
  |   If not, what guarantees are made with respect to synchronization externally?
We are locking parts of the Controller code that change states.
So if one thread moves context fwd, the next thread will wait, and then see that this was already moved.
Meaning you pojo will only go through states exactly once.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4130838#4130838

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4130838



More information about the jboss-user mailing list