Why do you expect there to be a comment justifying it? It's necessary to lock all collections while iterating over or modifying them if they can be vulnerable to concurrent modification.
-----Original Message-----
From: oyvindharbo..mail.com [mailto:oyvindharboe@gmail.com] On Behalf Of Øyvind Harboe
Sent: Friday, June 20, 2008 3:42 PM
To: use..ayenne.apache.org
Subject: Re: weakly referenced paged queries
On Fri, Jun 20, 2008 at 7:34 PM, Scott Anderson <sanderso..irvana.com> wrote:
> It looks like the synchronized block is designed to prevent concurrent modification
> of the list. I don't believe that particular code would suffer the consequences
> if concurrent modification occurred, but it's generally best to synchronize
> list access when in doubt, since even a simple iteration can be the offender.
I find that code that is added because one hasn't defined what the
interface should be, is trouble waiting to happen.
I would be much more comfortable, if either:
- the JavaDoc explained *why* the synchronization is there and what it
is supposed to do and how the client is supposed to use it.
- it serves some internal purpose and that purpose was stated as a comment
in the code
- the synchronization code was deleted(faster + less chance of deadlock).
-- Øyvind Harboe http://www.zylin.com/zy1000.html ARM7 ARM9 XScale Cortex JTAG debugger and flash programmer
This archive was generated by hypermail 2.0.0 : Fri Jun 20 2008 - 17:58:31 EDT