java - Netty: Concurrency issues using multiple event loops -


i have 1 client connecting n different servers. so, creating n different channels.
because servers more 5000. using 10 event loops 1 event loop group.also, there separate pipeline each channel.
know there no concurrency problem if use 1 event loop , have not seen concurrency problem on 10 event loops yet.my question is:
will having concurrency problem on line healthtargets.storehealthytarget(inetaddress.getbyname(remoteaddress)); in below piece of code , why?
suspect there concurrency problem.because, if multiple event loops not accessing this, point being using multiple event loops?

 @override     protected void channelread0(channelhandlercontext channelhandlercontext, httpobject httpobject) throws unknownhostexception {         if(channelhandlercontext.channel().remoteaddress() != null)         {             string remoteaddress = remoteaddress(channelhandlercontext.channel().remoteaddress().tostring());             if (httpobject instanceof httpresponse) {                 httpresponsestatus responsestatus = ((httpresponse)httpobject).getstatus();                 if (responsestatus.code() == httpresponsestatus.ok.code())                 {                     healthtargets.storehealthytarget(inetaddress.getbyname(remoteaddress));                 }             }         }     } 

here healthtargets.storehealthytarget using hashset store ip , healthtargets singleton class.

if share same instance of set (which seems do) between different eventloops run issues. because different channels may run on different eventloops , threads. has effect need make access of healthtargets thread-safe.

this not different other multi-threaded program.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -