Hello,

I am experimenting with Apache Mina and currently have unclear point:

In NioSocketAcceptor acceptor = new NioSocketAcceptor(2);
I  specify the number of acceptors. As fa as I understand they do not
work in separate threads. When I try to perform long operation in
IoHandlerApadter.messageReceived and new connection is established, a
free NioAcceptor is working, e.g. code with 2 NioAcceptors work:

public class MyIOHandler extends IoHandlerAdapter {
...........
private static long number = 0;
public void messageReceived(IoSession session, Object message) throws
Exception {
        number++;
        if (number == 1) {
          while(true) { }
        }
}
...........
}

the first NioAcceptor buisy, when new connection required, the second
remaining acceptor takes over

I wonder why it works if I have only 1 thread (with no
ExecutorFilter)? What is the philosophy behind Mina acceptors? Is code
inside IoHandlerAdapter thread safe or I must perform synchronization?

Thank you

Reply via email to