Discussion and application of Java Thread (conversion)
Source: Internet
Author: User
Discussion and application of Java Thread
Longshigong
I. Why should we study and use the thread?
Generally speaking, the computer is calling the process in the execution order ), there are different address spaces in the process, and they are different in the same sequence, such as w o r d and Excel, the interprocess communication is very expensive and limited.
The process of text-switching and change-and-operation is also not complex.
Inter-process communication complex, you can need to manage channels, message queue, and shared memory (sharedmemory) or the letter is handled to guarantee the communication between the process.
Although many projects are running, only one program can be submitted at a time.
Thread refers to the single-forward control flow in the process.
It is also called a lightweight process.
A thread shares the same address space and constructs a large progress.
The interthread communication is not always simple and effective, and the upper and lower texts are switched to an extremely fast and whole big process order.
The thread is only used for scheduling, and they stand alone, and the thread must be in an applicable sequence, programming is more self-developed and rich.
The interest of the thread is that multiple threads are used to complete different tasks in the same process of a thread.
As a result, if you use the line program well, you can use the process sequence to describe it in large and simple ways.
Multi-thread can increase the interconnectivity of the process order to provide better capabilities and capabilities, better GUI and better server capabilities.
The following is a description of the two examples:
Example 1: Using a multi-thread parallel computer system, you can easily solve many questions in the cross-line network connection sequence, such: for a large number of Internet file resource Source reading and writing, user-input response, and motion picture display questions, there is no need for many periods of c p u; however, the complex calculation during consumption usually does not need to respond immediately. Therefore, the c p u must be provided to it.
For example, it may take one minute to read a data stream from a slow network, however, when the c p u parameter is required and data transmission is required, data transmission is not always short. When the user enters an input key, such as a key, it is considered the fastest loser, the key is hit once every one second, and it does not require many periods of c p u.
When the ratio of the animation sequence is relatively high, a painting needs to be re-painted 5-1 0 times in 1 second, however, the c p u is still in the idle state in the big part time.
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