harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Axel Nielsen <erika...@stud.ntnu.no>
Subject Re: [website] harmony-dev agreements and recommendations
Date Thu, 25 May 2006 18:26:55 GMT

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: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

View raw message