[concurrency-interest] thread queueing qn

Rémi Forax forax at univ-mlv.fr
Fri Jan 18 20:14:02 EST 2008


Dhanji R. Prasanna a écrit :
> Hi 
>
>  
> I am trying to sequence/queue HTTP requests in a semantic user 
> "conversation":
>
>  
> Incoming Request -> Filter (Identify by cookie or rewritten URL) -> 
> Read( by Id from ConversationStore ) -> setActive ( ConversationContext )
>
>  
>
> Each conversation is modeled as a ConversationContext object that may 
> be stored in a permanent storage medium (custom impl by a user). My 
> solution is to obtain the ConversationContext from a store (creating a 
> new one as necessary) and then synchronizing on it while processing 
> the request:
>
>  
> doFilter( ...) {
>
>  
>    ConversationContext con = readFromStoreById(..);
>
>    synchronized(con) {
>          filterChain.doFilter(...);     //process request normally
>    }
>
>  
> }
>
>
>  
> This gives me queueing so that no two requests belonging to the *same* 
> user conversation are processed concurrently. However I see a couple 
> of drawbacks:
>
> - synchronizing on a public object from a store is potentially 
> dangerous, as poorly written user impls can deadlock or starve request 
> threads
> - as an alternative, I don't want to force/trust users to expose a 
> locking API
and it can don't work at all because lot of persistence storages use 
equals() semantics (two persistent objects are equals using equals())
and synchronized use == semantic.

...
> Thank you,
>
> Dhanji.
Rémi


More information about the Concurrency-interest mailing list