• Post Reply Bookmark Topic Watch Topic
  • New Topic

90% CPU -problem with thread in NIO  RSS feed

 
Dave Jones
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I have a multi-threaded server written in non blocking NIO (one thread
handles the IO) and after a while i see that it uses
about 90% CPU. I managed to find the thread that causes the problem, and
it is the one handling the IO but i need help understanding the
reason for it, please take a look:
Thanks


I noticed that the problem only started after I got a null pointer
exception in the line: connectingChannel.write...
The thread has a while(true) loop surrounding a try...catch... that
catches this exception and continues normally.



The reason for the 90% CPU is that ioHandlerSelector.select(1000)
returns immediately (after the exception), and it's surrounded by a
while(true) loop (Every 1-3 ms i see a "no ready channels" msg)


What can be the problem?
Thanks again
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't you have to wait until the channel becomes writable (after connecting) to be able to write to it?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!