On 25. mai. 2006, at 17.42, Geir Magnusson Jr wrote:
Time for me to learn something - I thought there was only one
monitor per object.... how can different threads get different locks?
Hi, as I understand it, you use final on monitors to prevent the
following from happening:
Let's say you have a monitor:
private Object monitor;
Then you somewhere have:
public foo() {
monitor = new Object();
}
If by any chance foo() should be called twice you in effect have two
monitors around. One before foo was called the second time (and some
thread may hold a lock on it) and one after. The monitor should of
course not be made in such a method, but the idea is that by making all
monitors final you are sure you don't make this mistake.
So if anyone asked me, I'd say +1 to the final on monitors guideline.
geir
-- Erik Axel
---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]