Scala / Java 中的 NIO 问题是什么?
在网上搜索 jvm 中的并发性时,我发现了有关搜索 Scala / Java 的非阻塞 IO 库的问题。
问题出在哪里?如果我想发送一些东西到文件/套接字,我可以启动单独的线程来完成这项工作。
我知道使用基于事件的线程可能会出现问题 - 因为整个系统可能会被阻塞。但它引用了 JVM/Scala 吗?
添加:
如果我错了,请纠正我:
我认为当您需要以异步方式调用某些 IO 函数时,它需要进入单独的进程或系统(重)线程。我说得对吗?
因此,有关用通用语言解决此类问题的所有问题都涉及创建和管理单独的进程或线程。因此,该语言的唯一便利是创建一些线程池,这些线程池将分配给异步 IO 操作。
所以我的假设是。
句子:语言 X 比 Y 更好,因为调用异步 IO 操作不会阻塞虚拟机是错误的,因为在每种支持系统线程的语言中都可以管理 NIO,唯一的区别是语言X 通过内置库/语言功能对此提供了更好的支持。
- 这个假设是真的吗?
- 某些语言可以在没有操作系统支持的情况下实现NIO吗? (通过进程/线程)
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.
- Is this hypothese Truth?
- Can some language achieve NIO without os system support? (through processes / threads)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Scala 有很多并发工具,NIO 有一些非阻塞 IO 工具。因此,有很多优秀的库可以帮助连接这些点也就不足为奇了:
Finagle< /a>
<块引用>
...用于构建的库
异步 RPC 服务器和客户端
Java、Scala 或任何 JVM 语言。
Finagle 构建于 Netty 之上,提供了
丰富的协议工具集
独立。
Akka 是一个非常漂亮、功能齐全的 actor/concurrency/services 包,它还使用 Netty 来实现内置的远程处理功能
Naggati2 是 Twitter 的另一个功能,也是基于 Netty 构建的,不确定它是否会被取代不过 Finagle。
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
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.
这是最近一篇有趣的博客文章,可能会对您有所帮助: http://jim-mcbeath.blogspot.com/2011/03/java-nio-and-scala-continuations.html
Here is an interesting recent blog post that may help you: http://jim-mcbeath.blogspot.com/2011/03/java-nio-and-scala-continuations.html