harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Ellison <t.p.elli...@gmail.com>
Subject [classlib] Recognizing lock objects
Date Tue, 03 Oct 2006 16:31:59 GMT
There are a number of places in the class library code where we create
an object solely to use as a synchronized block 'lock'.

For example, in RandomAccessFile we define a

  private Object repositionLock = new Object();

then in a number of methods
  public int read()..
   ..
   synchronized(repositionLock) {
     ...
   }

you get the idea.

Using an instance of Object makes it hard to see (in profiling tools)
which lock objects are 'hot', or how often a particular lock object is used.

I'd like to replace the generic Object instance with a private type just
for the purpose, like this:

    private class RepositionLock {}
    private Object repositionLock = new RepositionLock();

The usage would be the same, but it will then be easier to see if
RandomAccessFile$RepositionLock becomes a choke point.

Any objections or improvements to this proposed 'pattern' and putting it
into various places throughout the class library?

Regards,
Tim

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Mime
View raw message