cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Gentry" <blackn...@gmail.com>
Subject Re: Thread safety and Cayenne ( & Tapestry)
Date Fri, 29 Sep 2006 14:03:08 GMT
Well, since this is your visit (session) instance, shouldn't only one
thread at a time be accessing the list?

/dev/mrg


On 9/29/06, Øyvind Harboe <oyvind.harboe@zylin.com> wrote:
> Where can I read more about Cayenne and behaviour of objects when
> accessed from multiple threads simultaneously?
>
>
> We've screwed up a bit(how much I need to find out :-) when using
> Tapestry + Cayenne, but things work surprisingly well even so. That
> things appear to work fine is perhaps the scariest thing. I'd rather
> they'd break immediately.
>
> Basically we have multiple threads accessing/modifying a list of
> CayenneDataObjects.
>
> The problems started in our Visit object implementation in Tapestry:
>
> class Visit
> {
>   public List getFoo()
>   {
>     if (list==null)
>     {
>       List l=someCayenneQuery();
> Thread.sleep(5000);  // (A)
>       list=l;
>     }
>     return list;
>   }
> }
>
>
> Several problems:
>
> - There is a race condition. Context switch at (A) and a subsequent
> getFoo() invocation will will cause any number of someCayenneQuery()
> method calls thus each thread may be operating on a different list of
> objects.
> - Items might be added/removed from multiple threads. A simple
> LinkedList() is not thread safe, what about something returned from a
> Cayenne query?
>
> - How will a CayenneDataObject respond to multiple threads modifying properties?
>
> - How will a CayenneDataObject respond to multiple threads reading properties?
>
>
> Possible solutions for us that I'm pondering:
>
> - Read up more on Cayenne to understand the threading model better.
> Multiple threads reading/writing the same CayenneDataObjects may be
> fine.
> - I could single thread all modifications of the session/visit state.
> - use serialization somehow to create and write back a copy of each
> object per HTTP request.
> - Does some framework which can be used with Cayenne & Tapestry exist
> that can help me address the issues?
> - Can I make my Tapestry application single threaded? (I believe the
> answer is Bad Idea :-)
>
>
> --
> Øyvind Harboe
> http://www.zylin.com
>

Mime
View raw message