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: Tore Halset (halse..vv.ntnu.no)
Date: Fri Oct 24 2008 - 08:22:07 EDT

  • Next message: Andrey Razumovsky: "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"

    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:22:50 EDT