File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes 90% CPU -problem with thread in NIO Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "90% CPU -problem with thread in NIO" Watch "90% CPU -problem with thread in NIO" New topic
Author

90% CPU -problem with thread in NIO

Dave Jones
Ranch Hand

Joined: Feb 20, 2005
Posts: 77
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

Joined: Aug 07, 2003
Posts: 1646
Don't you have to wait until the channel becomes writable (after connecting) to be able to write to it?
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: 90% CPU -problem with thread in NIO
 
Similar Threads
ServerSocketChannel.accept() seems to create a random port to send data to?
Using NIO for Client Sockets
server can not accept all the clients connection request
does a nio socket buffer data internally too?
NIO question