Your reply is very helpful but I'm not english speaker so I should check what I 
understand.
Below is sample of my code.
getConnect() method return global instance.
Should I add synchronized statement or not?

        public void sessionClosed(IoSession session) throws Exception {
                reconnectSession(session);
        }

        static public void reconnectSession(final IoSession session, final 
NpsConf npsConf, final Integer index) {
                Thread thread = new Thread(new Runnable() {
                        public void run() {
                                try {
                                        ...
                                        final IoConnector connector = 
MainContext.getInstance().getConnector();
                                        connectFuture = 
connector.connect(ipAddress, port);
                                        ...

or

                                        ...
                                        final IoConnector connector = 
MainContext.getInstance().getConnector();
                                        synchronized(connector) {
                                                connectFuture = 
connector.connect(ipAddress, port);
                                        }
                                        ...

Which is correct?

-----Original Message-----
From: Emmanuel Lécharny [mailto:[email protected]] 
Sent: Monday, December 01, 2014 6:26 PM
To: [email protected]
Subject: Re: Are all MINA APIs thread unsafe except IoSession?

Le 01/12/14 07:38, 주재경 a écrit :
> I'm very thanks for your quick response.
>
> Upgrading MINA version is next choice and I should find out problem in 
> current using version and situation ^^

First upgrade. Your problem may already be solved. Never underestimate the 
power of BUGS !
>
> I'm wondering thread safety of all method because it isn't commented 
> explicitly.
> Especially, I have a question about thread safety of 
> NioSocketConnector.connect() method.
> I'v defined a global NioSocketConnector object and using in different thread 
> because of reconnecting.
> Should I synchronized the connector?

You should be safe using the onnector instance, assuming your codec is thread 
safe (and assuming you haven't added some logic in the chain).


Reply via email to