Tim Ellison wrote:
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();
Why "RepositionLock"? (curious about origin of the name)
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?
I like it. But, any benefit to having a general class
o.a.h.whatever.LockObject rather than class private?
geir
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]