[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Locks on MainDeployerImpl
bstansberry@jboss.com
do-not-reply at jboss.com
Fri Feb 20 14:53:29 EST 2009
No, you don't need to because you are using Collections.synchronizedMap. The map it returns synchronizes on itself in all methods to prevent concurrent access. So synchronizing on it will prevent other threads mutating it in the middle of the two calls.
There's some obscure aspect to this I won't go into details here (unless you want), but for reference, this is discussed in detail in section 5.1.1 of Java Concurrency in Practice.
You could make toRedeploy a plain HashMap and then put all the calls on it in a synchronized block. That would have the same effect and would be more understandable.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4211943#4211943
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4211943
More information about the jboss-dev-forums
mailing list