什么选项的async io(基于套接字)在java其他然后java.nio? java.nio还使用backround中的线程(正如我认为.NET的async-socket-library所做的那样,或许已经被更改),或者是使用正确的select调用“true”async io?
What options for async io (socket-based) are there in java other then java.nio? Also does java.nio use threads in the backround (as I think .NET's async-socket-library does, maybe it's been changed) or is it "true" async io using a proper select call?
最满意答案
Java的NIO包(从Java6开始)仅通过选择器提供对非阻塞I / O的支持。 Java7希望随NIO.2一起出货,其中包括异步I / O支持。 今天,你最好的办法是利用一个框架。 ARMistice提到了米娜。 这里有一些。
灰熊 这是Sun的GlassFish服务器的I / O核心。 Grizzly提供了进行异步读/写(通过队列模型)的功能。 它支持TCP和UDP。 我在几个项目中使用了灰熊。 有一些我喜欢和不喜欢的框架,但是细节这是另一个话题。 我会说,这是很容易得到一些运行和灰熊为你做了很多重的举措。 网吧 这个项目来自于Mina项目的原创作者之一。 我没有使用这个,所以我不知道它对异步I / O的支持。 你应该看看。现在,关于你对线程的问题,NIO选择器不使用线程进行非阻塞I / O。 在JDK6中,他们使用Windows下的select()和更新的Linux内核上的epoll工具。 对于异步I / O,线程细节取决于框架。
Java's NIO package (as of Java6), provides support for non-blocking I/O only, via Selectors. Java7 is hopefully going to ship with NIO.2, which includes asynchronous I/O support. Today, your best bet is to make use of a framework. ARMistice mentioned Mina. Here are some others.
Grizzly. This is the I/O core for Sun's GlassFish server. Grizzly provides a facility for doing asynchronous reads/writes (via a queue model). It supports TCP and UDP alike. I've used Grizzly in a couple of projects. There are things I like and dislike about the framework, but to detail this is really another topic. I will say that it's quite easy to get something up and running and Grizzly does a lot of the heavy lifting for you. Netty. This project comes from one of the original authors on the Mina project. I haven't used this one so I don't know about about its support for asynchronous I/O. You should take a look.Now, with regard to your question about threads, NIO Selectors do not use threads for non-blocking I/O. In JDK6 they use select() under Windows and the epoll facility on newer Linux kernels. For asynchronous I/O, threading details depend on the framework.
更多推荐
发布评论