<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Calvin's Tech Space

    成于堅忍,毀于浮躁

       :: 首頁 :: 聯系 :: 聚合  :: 管理

    參見
    The Rox Java NIO Tutorial

    一些principles
    1.Use a single selecting thread
    雖然selector本身是線程安全的,但是key集合卻不是線程安全的,使用多線程容易導致死鎖。

    2.Use a single selecting thread
    NIO底層實現在不同的平臺上是不一樣的,如果你編寫的程序可能要在不同的平臺上運行,那么必須遵循這一原則。
    更改行為包括:修改一個select key感興趣的ops,向這個selector注冊新的channel或者從這個selector取消一個channel等。

    3.Set OP_WRITE only when you have data ready
    A common mistake is to enable OP_WRITE on a selection key and leave it set. This results in the selecting thread spinning because 99% of the time a socket channel is ready for writing. In fact the only times it's not going to be ready for writing is during connection establishment or if the local OS socket buffer is full. The correct way to do this is to enable OP_WRITE only when you have data ready to be written on that socket channel. And don't forget to do it from within the selecting thread.

    4.Alternate between OP_READ and OP_WRITE



    posted on 2009-12-27 13:55 calvin 閱讀(412) 評論(0)  編輯  收藏 所屬分類: Java
    主站蜘蛛池模板: 久久免费看黄a级毛片| 美女在线视频观看影院免费天天看 | 无遮免费网站在线入口| 91嫩草私人成人亚洲影院| 久久久免费精品re6| 久久久久亚洲Av无码专| 18级成人毛片免费观看| 亚洲精品国产成人中文| 亚洲一区二区免费视频| 久久久久亚洲国产| 国产成人精品123区免费视频| 国产大陆亚洲精品国产| 亚洲第一区精品日韩在线播放| 国产黄色片免费看| 久久久无码精品亚洲日韩蜜桃| 一级做a爰全过程免费视频| 亚洲最大黄色网站| 黄色成人网站免费无码av| 亚洲avav天堂av在线网毛片| 亚洲一区二区视频在线观看 | 在线观看免费无码专区| 婷婷亚洲久悠悠色悠在线播放| 久视频精品免费观看99| 亚洲色大成网站www尤物| 国产成人免费手机在线观看视频| 日韩在线观看免费完整版视频| 国产亚洲一区二区三区在线| 最近最新高清免费中文字幕| 亚洲精品伊人久久久久| 亚洲 综合 国产 欧洲 丝袜 | 亚洲开心婷婷中文字幕| 91青青国产在线观看免费| 亚洲中文精品久久久久久不卡| 亚洲第一区精品观看| 99视频免费观看| 亚洲国产精品99久久久久久| 亚洲一区二区三区无码中文字幕 | 免费毛片a线观看| 亚洲情A成黄在线观看动漫软件| 婷婷亚洲天堂影院| 91热久久免费精品99|