I am currently working on performance of a distributed application. I am targeting a network component. Currently for each connection there is a dedicated thread which handles a socket in blocking mode. My goal is to reduce number of threads(without reducing performance) and if possible improve performance.
I redesigned the network component to use async communication and am trying to use 1 to 2 threads for entire network processing. I did a simple test where I wrote in a loop from one node and read on another, This was to test max nw thread capability and I found that my busy loop implementation was consuming 100% cpu and was getting much more operations per sec then we require. So I integrated this busy loop implementation in the existing application.
Problem I found is that other threads are not allowing these async nw threads to aquire full cpu, even though I have a 8 core system and we are not using more than 400% cpu. Basically being a C programmer I would have solved this by binding my nw thread on a core and raising its scheduling priority, so that other threads can still run on other core. I am not able to do similar in Java. There are conflicting comments on Java thread priority. Also I do not want to reduce the priority of other threads as it may have its own side affect.
How would you solve this problem?