On 7/31/07, James Im <[EMAIL PROTECTED]> wrote:

<snip/>

> >And the callers of wakeup() calls
> >wakeup() mostly after some synchronized block (e.g.
> >IoSession.write()), so the possibility that something goes wrong is
> >very close to zero.
>
> I don't understand this very well. There are 2 problematic methods:
> - SocketIoProcessor.flush() is called by SocketFilterChain.doWrite() and
> synchronizes around the Queue<WriteRequest>. This has nothing to do with
> the selector reference I'm talking about. I don't see the relation.
> - SocketIoProcessor.updateTrafficMask() is called by
> SocketSessionImpl.updateTrafficMask() and I don't see any
> synchronization there.
>
> I don't know if somewhere you imply that, after one second, the
> visibility problem will go away.

Isn't the working memory of the current thread synchronized whatever
monitor (lock) is acquired and released?  So I thought acquiring
different locks doesn't matter.  Please correct me if I am
misunderstanding JMM.  If it's wrong, we definitely need to fix it.

And regarding updateTrafficMask(), yeah, we need to fix it.

> >so the possibility that something goes wrong is very close to zero.
>
> If I tell you the truth, I don't like this sentence for the following
> reason. I read your sentence like that: as the probability of a bug is
> very low, the code is good enough, let's not fix it. With concurrency
> you cannot play tricks. It is not enough that that the program works in
> practice most of the time. As you cannot reproduce many concurrency
> bugs, the code must be right. Concurrency is hard, and a program is
> either safe or not. It is either black or white, even if it is hard
> sometimes to see which color it is. That said, I agree that the risk is
> low...
>
> So for the case that we're talking about, I think that we agree that
> we've found a potential problem. The question is not then IF it will be
> a problem in practice or not, but rather HOW do we fix it. I believe
> that making the selector volatile could fix the problem. IF I am correct
> it should be done, unless another way to fix the problem is proposed.

I agree with you.  Because volatile doesn't work very well in Java
1.4, what do we need to fix the problem in 1.0?  Would using
synchronized block hurt performance?

> I hope I have not offended you or anyone here.

Of course not.  I appreciate your heathy criticism.  :)

Cheers,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Reply via email to