Java NIO 備忘

來源:互聯網
上載者:User

標籤:

$.backlog:
可以把它簡單理解為一個 listening socket 的請求串連隊列的限制。當隊列中的串連請求達到隊列限制時,kernel 會拒絕信的串連請求。只有當應用程式通過 accept 方法從隊列中取出串連請求,使隊列騰出空位時,隊列才能繼續加入新的串連請求。對於用戶端進程,如果其發出的請求被拒絕,則會拋出拒絕串連的異常。

$.SelectableChannel.register:
This method will then synchronize on the selector‘s key set and therefore may block if invoked concurrently with another registration or selection operation involving the same selector.
另外,就算在 register 前調用 wakeup 這麼做也不是百分百保證能夠喚醒,如果 wakeup 後當前進程掛起,又切換到了 select,register 還是會被掛起,不過幾率比較低。有一個解決方案是 select 加一個逾時時間,即 select(timeout),但這不是最優的。
參考:http://stackoverflow.com/questions/1057224/thread-is-stuck-while-registering-channel-with-selector-in-java-nio-server

Java NIO 備忘

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.