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