<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
    主站蜘蛛池模板: 中文字幕免费观看| 黄色网址大全免费| 97av免费视频| 亚洲成AV人片在线观看无| 一区在线免费观看| 在线亚洲97se亚洲综合在线| 亚洲一级片免费看| 亚洲人成电影在线播放| a级毛片免费观看在线| 亚洲Av永久无码精品三区在线| 两性色午夜视频免费网| 情人伊人久久综合亚洲| 久久免费观看国产99精品| 久久亚洲私人国产精品| 成人爽A毛片免费看| 美女被免费视频网站| 亚洲色大成网站www永久一区| 免费在线中文日本| 亚洲黄色网站视频| 成人免费视频试看120秒| 久久精品国产亚洲AV| 亚洲综合色在线观看亚洲| 日本高清高色视频免费| 一区二区亚洲精品精华液| 免费一级毛片不卡在线播放| 国产99久久久国产精免费| 国产亚洲精品岁国产微拍精品| 一级毛片免费毛片一级毛片免费| 亚洲乱码一区av春药高潮| 免费一级做a爰片久久毛片潮喷| 中文字幕无码免费久久9一区9 | 亚洲狠狠狠一区二区三区| 性色av无码免费一区二区三区| 国产精品亚洲综合网站| 亚洲精品高清无码视频| 三年片在线观看免费观看高清电影| 亚洲经典千人经典日产| 亚洲av日韩av不卡在线观看 | 国产成人亚洲毛片| 亚洲成人中文字幕| 国产精品黄页在线播放免费|