Java NIO: I/O model
Maybe many friends will find it a bit difficult when learning NIO, and many concepts in it are not so clear. Before entering Java NIOProgramming, let’s discuss some basic knowledge today: I/OModel. The following article starts with the concepts of synchronization and asynchronous, then explains the difference between blocking and non-blocking, then introduces the difference between blocking IO and non-blocking IO, then introduces the difference between synchronous IO and asynchronous IO, and then introduces 5 IO models, and finally introduces two design patterns (Reactor and Proactor) related to high-performance IO design.
The following is the table of contents outline of this article:
1. What is synchronization? What is asynchronous?
2. What is blocking? What is non-blocking?
3. What is blocking IO? What is non-blocking IO?
4. What is synchronous IO? What is asynchronous IO?
Five. Five IO models
Six. Two high-performance IO design patterns
If there are any irregularities, please forgive me and welcome criticism and corrections.
1. What is synchronization? What is asynchronous?
The concepts of synchronization and asynchronousness have been around for a long time, and there are many opinions about synchronization and asynchronousness on the Internet. The following is my personal understanding:
Synchronization means: if there are multiple tasks or events to occur, these tasks or events must be carried out one by one. The execution of one event or task will cause the entire The process is temporarily waiting, and these events cannot be executed concurrently;
Asynchronous means: if multiple tasks or events occur, these events can be executed concurrently, and the execution of one event or task will not cause the entire process to fail. Wait for now.
This is synchronous and asynchronous. To give a simple example, if there is a task that includes two subtasks A and B. For synchronization, when A is executing, B can only wait until A is completed, and then B can execute; for asynchronous, A and B can be executed concurrently, and B does not have to wait for A to finish executing, so that the execution of A will not cause the entire task to wait temporarily.
If you still don’t understand, you can read the following two pieces of code first:
##12345 678910111213 14 |
|
This code is a typical synchronization. In the method function, the execution of fun1 will cause the subsequent fun2 to be unable to execute. Fun2 must wait for the execution of fun1 to complete before it can be executed.
Then look at the following code:
##123456 7891011121314 15161718192021222324 |
|
##1234567 |
#while
|
The above is the detailed content of Java NIO: I/O model. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Troubleshooting and solutions to the company's security software that causes some applications to not function properly. Many companies will deploy security software in order to ensure internal network security. ...

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

Field mapping processing in system docking often encounters a difficult problem when performing system docking: how to effectively map the interface fields of system A...

Start Spring using IntelliJIDEAUltimate version...

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...
