Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is about NIO problems in Scala / Java

While searching the web for concurrency in jvm I found questions about searching Non-blocking IO library for Scala / Java.

What is the problem about? If I want to send something to file / socket I can launch separate thread which make the job.

I know there could be problem using event based threads - because whole system could be blocked. But does it reference to JVM/ Scala?

ADDED:
Please correct me if I'm wrong:
I think that when you need to call some IO function in asynchronous way it need to go into separate process or system (heavy) thread. Am I right?
So - all the questions about solving this kind of thing in common languages goes into creating and managing separate process or threads. So the only facilitate from the language is to create some pool of threads which will be assigned to IO operations in async.

So my hypotheses is.
Sentence: Language X is better then Y because calling async IO operation dosen't block the virtual machine is false because in every language that support system threads there is possibility to manage NIO, the only difference is that language X has better support for this through builtin libraries / language features.

  1. Is this hypothese Truth?
  2. Can some language achieve NIO without os system support? (through processes / threads)
like image 961
Robert Zaremba Avatar asked Mar 25 '11 19:03

Robert Zaremba


2 Answers

Scala has a bunch of tools for concurrency, and NIO has a few tools for non-blocking IO. So, it should come as no surprise that there are a lot of great libraries that help connect the dots:

  • Finagle

    ... a library for building asynchronous RPC servers and clients in Java, Scala, or any JVM language. Built atop Netty, Finagle provides a rich set of tools that are protocol independent.

  • Akka is a pretty nice, featureful actors/concurrency/services package which also uses Netty for their built-in remoting functionality

  • Naggati2 is another one from Twitter, also built on Netty, not sure if it's being superseded by Finagle though.

like image 136
Alex Cruise Avatar answered Nov 09 '22 07:11

Alex Cruise


Here is an interesting recent blog post that may help you: http://jim-mcbeath.blogspot.com/2011/03/java-nio-and-scala-continuations.html

like image 2
0__ Avatar answered Nov 09 '22 07:11

0__