Yes, you are right: different threads can get different locks only on
different objects.
Lets see BenContextSupport code as example:

private void addChild(Object targetChild) {
// Add a new child using targetChild as a key and
// its BCSChild instance as an entry
synchronized(this.children) {
   BCSChild ch = createBCSChild(targetChild, getBeanContextPeer());
   this.children.put(targetChild, ch);
   childJustAddedHook(targetChild, ch);
}
  // Fire memebership event
  fireChildrenAdded(getBCME(new Object[] { targetChild }));
}


'this.children' is not final and even not private -> so developer
allows to change this field in runtime. But if field can be changed the
methods in synchronized block can be called simultaneously by different
threads. Today everything is OK with this code. But in future this could be
a reason for a bug.

On 5/25/06, Geir Magnusson Jr <[EMAIL PROTECTED]> wrote:


Time for me to learn something - I thought there was only one monitor
per object.... how can different threads get different locks?

geir


--
Mikhail Fursov
Intel Middleware Products Division

Reply via email to