In computer programming, there is a basic concept that is the idea of dealing with multiple tasks at the same time.
Many programs require the program to stop the work being done, turn to other issues, and then return to the main process.
First, let's take a look at the parallel and concurrent relationships:
Parallelism means that multiple tasks are handled at the same time, and concurrency refers to multiple tasks that can be run independently and run independently and in a certain period of time.
Realize:
Initially, programmers use the knowledge of the underlying machine to write interrupt service programs, the main process is suspended by a hardware interrupt to trigger, but too difficult, and can not be ported. Interruptions are necessary for time-intensive tasks, but for a large number of other problems, we just want to split the problem into multiple independent parts (tasks), which can improve the responsiveness of the program. In the program, the parts that run independently of each other are called threads.
Typically, a thread is simply a means of assigning execution time to a single processor, but if the operating system supports multiple processors,
Then each task can be assigned to a different processor, and they are really parallel execution (not a time period)
At the language level, the convenience of multithreading is that programmers don't have to worry about whether the machine is multiple processors or a processor,
Because the program is logically divided into threads, if the machine has multiple processors, it does not require a special tuning program to perform faster.
Concurrency vulnerability: sharing resources
When multiple parallel tasks have access to the same resource, the resource is locked for a task, and when completed, resources are freed for use by other tasks.
Java concurrency and multi-processor parallel understanding