cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <>
Subject Re: Standalone app, Threads and Object contexts
Date Wed, 02 May 2012 16:37:44 GMT
Hi Andrew,

I do not believe you want to share a context like that.  A DataContext
is NOT thread safe between different threads.  Also, even if you
synchronized access to it further (to be thread safe), a single commit
failure (such as a constraint exception) would doom all future commits
because the shared DataContext is now dirty with uncommitable changes
and nothing else can commit, either.

Use individual DataContexts for related changes.  If you re-use a
DataContext, it should be applicable to a previous request (just like
a web session re-attaches your HTTP Session).


On Wed, May 2, 2012 at 11:34 AM, Andrew Willerding
<> wrote:
> But just to confirm my understanding.  I can create one
> DataContext(ObjectContext) and perform as many "simultaneous i.e. from
> multiple threads" object creations, object updates, stored procedure
> executions without concern as long as these creations/updates/stored
> procedure executions are non-related and independent meaning one thread
> that's doing a creation/update/stored procedure execution is not dependent
> on a creation/update/execution going on in another thread.  Something like
> this

View raw message