harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Fursov" <mike.fur...@gmail.com>
Subject Re: [website] harmony-dev agreements and recommendations
Date Thu, 25 May 2006 18:33:15 GMT
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 <geir@pobox.com> 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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message