users@grizzly.java.net

Re: DefaultConcurrentCometHandler

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Tue, 25 Aug 2009 12:23:33 -0400

Salut,

felixx wrote:
> Probably I'm missing something here but I was wondering if in the
> DefaultConcurrentCometHandler, EnQueueEvent method, is it really necessary
> to have the onEvent call synchronized (this is the current code):
> .....
> synchronized(this){
> onEvent(event);
> }
> ....
> I'm under the impression that at any time only 1 thread would reach that
> point anyway and any other thread would end placing the event in the queue
> and return right way. So, why the sych?

I think it need to be synchronized because two threads can decide to
notify at the same time, and the onEvent will be invoked by two threads
at the same time, corrupting the response object.

Does it makes sense?

Thanks

-- Jeanfrancois



> Thanks.