Re: svn commit: r707569 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/ObjectContextStateLog.java test/java/org/apache/cayenne/remote/CayenneContextDeletionTest.java

From: Andrey Razumovsky (razumovsky.andre..mail.com)
Date: Fri Oct 24 2008 - 08:34:12 EDT

  • Next message: Andrus Adamchik (JIRA): "[jira] Closed: (CAY-1125) MySQL SMALLINT UNSIGNED is mapped as java.lang.Short, should be java.lang.Integer"

    Iterator.remove's cool, but here I need to call side functions, which
    perform deletion.

    As for ArrayList/Vector, here it doesn't matter because every function can
    be accessed by only one thread. We can change it if you wish.

    2008/10/24, Tore Halset <halse..vv.ntnu.no>:
    >
    >
    > On Oct 24, 2008, at 13:47 , Andrey Razumovsky wrote:
    >
    > The problem is NOT that some list is accessed by multiple threads. The
    >> problem is that java throws ConcurrentModificationException when you
    >> delete
    >> an object from the list while iteration over it. Two solutions I know from
    >> my experience are:
    >> 1. First do operations, and afterwards delete (done in the code).
    >> 2. Iterate through array with simple loop (e.g. for (int i = 0; i <
    >> list.size(); i++) - this helps in your case, because we have only one
    >> modification thread, but still I don't trust this code somewhy and try to
    >> avoid it. Also here we'll need to manually change the index (i-- when
    >> element is deleted).
    >>
    >
    > 3. Iterator#remove?
    >
    > Also note that there is just ONE thread accessing to the list, so all
    >> synchronization is useless and may result in deadlock!
    >>
    >
    > Okay, then you should probably not use Vector that is synchronized all
    > over?
    >
    > - Tore.
    >
    >



    This archive was generated by hypermail 2.0.0 : Fri Oct 24 2008 - 08:34:42 EDT