开发者

What is about NIO problems in Scala / Java

开发者 https://www.devze.com 2023-02-19 15:38 出处:网络
While searching the web for concurrency in jvm I found questions about searching Non-blocking IO library for 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 asynchro开发者_StackOverflow中文版nous 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)


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号