摘要: Epoll基本介绍在linux的网络编程中,很长的时间都在使用select来做事件触发。在linux新的内核中,有了一种替换它的机制,就是epoll。相比于select,epoll最大的好处在于它不会随着监听fd数目的增长而降低效率。因为在内核中的select实现中,它是采用轮询来处理的,轮询的fd数目越多,自然耗时越多。并且,在linux/posix_types.h头文件有这样的声明:#define__FD_SETSIZE1024表示select最多同时监听1024个fd,当然,可以通过修改头文件再重编译内核来扩大这个数目,但这似乎并不治本。epoll的接口非常简单,一共就三个函数:1.in 阅读全文
posted @ 2012-07-16 20:14 腾云生 阅读(847) 评论(1) 推荐(0) 编辑
摘要: Editor's note: This article refers to the Java Memory Model before it was revised for Java 5.0; statements about memory ordering may no longer be correct. However, the double-checked locking idiom is still broken under the new memory model. For more information on the memory model in Java 5.0, s 阅读全文
posted @ 2012-07-16 14:21 腾云生 阅读(202) 评论(0) 推荐(0) 编辑