Skip to content

Instantly share code, notes, and snippets.

@games647
Created March 3, 2020 10:06

Revisions

  1. games647 created this gist Mar 3, 2020.
    18 changes: 18 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    https://programming.vip/docs/java-non-blocking-io-and-asynchronous-io.html

    Differentiation into
    Blocking mode IO (Single thread)
    -> Often standard
    Asychrnous blocking IO
    -> many thready only waiting
    -> spawn a new thread for every blocking call
    Non-blocking IO
    -> single-thread can select over multiple connection and get notified on changes
    => Java Selector call
    -> worker can process changes
    => worker can be minimal only used for processing
    => less CPU overhead (thread creating + context switch between threads)
    => less memory overhead (holding cpu threads)
    => Java AsynchronousFileChannel / AsynchronousSocketChannel or similar
    => Linux: event system epoll used for networking - POSIX forbids it for files
    => Windows: networking + files