search

Home  >  Q&A  >  body text

java - 异步IO的优缺点

异步IO就是将数据从内核空间拷贝到用户空间放在了内核中进行, 所以用户进程或线程就可以在这段时间做其他事情. 这是他的优点, 但是他的缺点是什么呢?

PHPzPHPz2913 days ago559

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 10:14:10

    I think the shortcomings are:

    1. Multi-threaded programming is required, the threshold is high, and it is easy to write low-quality code.

    2. Synchronous serial programming is easier to understand than asynchronous callbacks.

    3. The code of asynchronous IO is relatively complex and not intuitive enough.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 10:14:10

    Recommended to take a look at RxJava
    Asynchronous programming, and you don’t have to deal with thread issues yourself
    If combined with lambda expressions, the logic is clear and the code is simple

    reply
    0
  • Cancelreply