Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我已经看遍了,但找不到一个很好的例子来解释 NIO2 或如何使用 Java 套接字进行异步 IO。例如,如果我想通过允许线程使用异步 IO 从套接字读取而不是常规同步 IO 来加速网络爬虫,我将如何实现这一点?
NIO2 并不比同步 I/O 快。它允许用几个线程运行许多连接(数万个)。如果您有能力为每个连接花费一个线程,请使用同步 I/O - 编程更简单。