Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Some doubt abt NIO usage ?  RSS feed

 
Saurabh Agrawal
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends ,
Back here with some doubts again .. well i want to know what is the significance of non blocking sockets in the new java io package or rarther NIO ??
Can anyone tell me this ??
Hoping to hear from you soon ,
Thanks,
Saurabh
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can do useful processing while waiting for more data to arrive over the network, non-blocking is a hnday way to just grab whatever data is available and continue processing. A more common use is in high-load servers. With blocking IO you need to spawn a new thread for each request which limits the number of simultanious request the server can handle and uses a lot of processor cycles switching back and forth between all the threads.
With non-blocking IO you can handle massive converrency without massive thread creation and you can accomplish useful things during periods of lag from network latency instead of just waiting for packets.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!