Interrupted IO and AWT

Jeff Sturm jsturm@sigma6.com
Tue Mar 21 12:31:00 GMT 2000


Tom Tromey wrote:
> Hans> Also I suspect that many Java locks are very short-lived. Thus
> Hans> it's important to avoid memory allocation when an object is
> Hans> first locked (statistics anyone?).
>> A paper I read recently suggests that in some situations it is
> worthwhile to avoid locks altogether when you can prove that an object
> is method- or thread-local ("Escape Analysis for Java", Choi et al --
> one of the Jalapeno papers). In this case we'd need to steal a bit
> somewhere (the gc header?) to indicate that the lock should be
> avoided. This is probably even more worthwhile if locks are heavy.

Surely the compiler could detect this in some cases... are you saying it
could be detected at runtime as well?
Tom, I think you mentioned once the use of locks for Java string
concatenation:
String f(int i) {
 return "f(" + i + ") called";
}
That method will normally do a monitorenter/monitorexit twice. Lock
avoidance may eliminate the useless locks in string contentation
completely.
-- 
Jeff Sturm
jsturm@sigma6.com


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /