Principles and examples of Java NIO

Source: Internet
Author: User

1. Reactor (reactor) mode

Use single-threaded simulation of multi-threading to increase resource utilization and program efficiency and increase system throughput. The following example compares the image of what a reactor pattern is:

A boss runs a restaurant,

Traditional mode-to a guest to arrange a waiter to greet, the guest is satisfied; (equivalent to a connection to a thread)

Later, more and more guests, the need for more and more waiters, the resource conditions are not enough to invite more waiters, the traditional model has been unable to meet the demand. Boss of the reason for the boss naturally have a place, the boss found that the waiter in the service for guests, when the guests order, the waiter is basically in a waiting state, (blocking threads, do not work).

So let the waiter in the guests order, to the other guests to serve, when the guests dish good after greeting waiter can. --the reactor (reactor) model was born

Hotel business is booming, a few waiters are enough to support a large number of passengers, the boss with limited resources to earn more money~~~~ ^_^

Principles and examples of Java NIO

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.