Home  >  Article  >  Java  >  What is bio in java

What is bio in java

(*-*)浩
(*-*)浩Original
2019-05-22 11:38:216135browse

The ios written in this article are all java bio system (i.e. io released by jdk1.0), which was the only choice before JDK1.4, but the program is intuitive, simple and easy to understand.

What is bio in java

BIO: Synchronize and block, the server implementation mode is one connection and one thread, that is, when the client has a connection request, the server needs to start a thread For processing, if this connection does not do anything, it will cause unnecessary thread overhead, which can of course be improved through the thread pool mechanism. The BIO method is suitable for architectures with a relatively small and fixed number of connections. This method has relatively high requirements on server resources and concurrency is limited to applications.

BIO
Synchronous blocking IO, I believe everyone who has studied operating system network programming or network programming in any language is familiar with it. In the while loop, the server will call The accept method waits to receive a connection request from the client. Once a connection request is received, a communication socket can be established to perform read and write operations on this communication socket. At this time, it can no longer receive connection requests from other clients and can only wait for the same request. The operation execution for the currently connected client is completed.
If BIO wants to be able to handle multiple client requests at the same time, it must use multi-threading, that is, each accept blocks and waits for a request from the client. Once a connection request is received, a communication socket is established and a new thread is opened for processing. The data read and write request of this socket, and then immediately continues to accept and wait for other client connection requests, that is, a thread is created for each client connection request to be processed separately. The approximate schematic diagram is like this:

What is bio in java

However, at this time the server has high concurrency capabilities, that is, it can handle multiple client requests at the same time, but it brings a problem. As the number of opened threads increases, it will consume Excessive memory resources can cause the server to slow down or even crash.

The IO method is suitable for scenarios where the number of connections is relatively small and fixed. This method has relatively high requirements on server resources and concurrency is limited to applications.

Related learning recommendations: java basic tutorial

The above is the detailed content of What is bio in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn