Java concurrency and multi-processor parallel understanding

Source: Internet
Author: User

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

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.