基于BIO的服务器,服务端可能要同时保持几百万个HTTP连接,而这些连接并不是每时每刻都在传输数据,所以这种情况不适合使用BIO的服务器:而且需要保证共享资源的同步与安全,这个实现起来相对复杂.这时候就是基于NIO的服务器出场的时候了. 先来比较下两种服务器的代码 1.NIO实现 public class SelectorServer { private static int PORT = 1234; public static void main(String[] args) throws E…
译文在后面. State Threads for Internet Applications Introduction State Threads is an application library which provides a foundation for writing fast and highly scalable Internet Applications on UNIX-like platforms. It combines the simplicity of the multi…