cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Anderson" <>
Subject RE: weakly referenced paged queries
Date Fri, 20 Jun 2008 21:57:35 GMT
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: [] On Behalf Of Øyvind Harboe
Sent: Friday, June 20, 2008 3:42 PM
Subject: Re: weakly referenced paged queries

On Fri, Jun 20, 2008 at 7:34 PM, Scott Anderson <> 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
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer

View raw message