• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

90% CPU -problem with thread in NIO

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic