mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Fisk"...@lastbamboo.org>
Subject Re: Rationale for Thread.sleep(1000) in Worker ?
Date Sat, 28 Jul 2007 18:28:26 GMT
I agree that would be very helpful.  A comment in that same method for this
chunk of code would also be very useful:

                    if (selector.keys().isEmpty()) {
                        synchronized (lock) {
                            if (selector.keys().isEmpty()
                                    && newSessions.isEmpty()) {
                                worker = null;

                                try {
                                } catch (IOException e) {
                                } finally {
                                    selector = null;


This relates to the question of visibility and possible use of volatile you
mentioned earlier.  Why are we stopping the selector here, only to seemingly
start it again when new sessions come in?  A comment would be great!  If
anyone's worried about their English, just an explanation on the list for
the rationale would be fantastic, and I'd be happy to submit a patch with
more fully commented code.


On 7/28/07, James Im <im-james@hotmail.com> wrote:
> I'm looking a little bit at the source code today and there is something
> that I don't understand.
> In the class SocketAcceptor.Worker, in the catch block there is a
> "Thread.sleep(1000);". I don't understand why you do that. What problem
> does this solve? Could you add a comment in the source that tells why
> this sleep is needed? That would be the best place to document this as
> its purpose is not obvious. Should I create a jira issue for that?
> } catch (IOException e) {
>     ExceptionMonitor.getInstance().exceptionCaught(e);
>     try {
>         Thread.sleep(1000);
>     } catch (InterruptedException e1) {
>         ExceptionMonitor.getInstance().exceptionCaught(e1);
>     }
> }
> _________________________________________________________________
> Ta' på udsalg året rundt på MSN Shopping:  http://shopping.msn.dk  - her
> finder du altid de bedste priser

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message