Java multithreading-Concurrency and parallelism

Source: Internet
Author: User

 1. Concurrency and parallelism differences
the difference between the two can be identified by the image:1) Definition: Concurrency:In the operating system, there are several programs in a period of time that are running from the start to completion, and these programs areSame ProcessorRun on, but at any point in timeonly one programRun on the processing machine. Parallel:in the operating system, a set of programs is executed independently and asynchronously , and the programs are executed together , both from the micro and macro level. to a metaphor: concurrency and parallelism is the difference between a person eat three steamed bread and three people at the same time eat three steamed bread;

In a single CPU system , the system is scheduled to run only one thread at a time, although there are many forms of this debug mechanism (mostly time-slice rounds), but in any case, it is called concurrency by constantly switching the threads that need to be run (concurrent ). In a multi-CPU system , you can allow more than two threads to run concurrently, which can be called parallel (parallel)in the same way that more than two threads run simultaneously.

2) Concurrency usually refers to the increase in runningon a single processorthe performance of the program;

Concurrency is stateful , "has demonstrable certainty, but is actually nondeterministic";

"Concurrency" is not at the same time in the micro-execution, but the time is divided into several paragraphs, so that multiple processes quickly alternating execution, from the macroscopic perspective, it seems that these processes are executing.

Using multiple threads can help us achieve higher throughput in a single processing system, and if a program is single-threaded, the processor is still idle while waiting for a synchronous I/O operation to complete. In a multithreaded system, when a thread waits for I/O, other threads can execute.








Java multithreading-Concurrency and parallelism

Related Article

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.