In the single-CPU system, the system operator at a time can only make one thread running, although there are many forms of this debugging mechanism (most of time Katawa main tour), but in any case, need to be run by continuously switching allowed to run the way the thread is called concurrency (concurrent). In multi-CPU system, two or more threads can run simultaneously, this can also allow two or more threads to run simultaneously is called parallel mode (parallel).
"Concurrent" in the implementation of the micro is not the same time, only the time into several sections, so that rapid alternation of the implementation of multiple processes, from outside the macro point of view, as if these processes are being implemented.
Use of multiple threads can help us in a single processing system to achieve higher throughput, if a program is single-threaded, this processor waiting for a synchronous I / O operation is complete, he is still free. In multi-threaded system, when a thread waiting for I / O, while the other thread can execute.
This bit spicy like a chef to do the time when so spicy chicken potato, spicy shredded chicken than do first do spicy fries speed, as it can alternately do.
Above this total is a single processor (chef) of the system processing tasks (cooking) the situation, only one chef, he was in a micro time, he can only do one thing, this is though multiple threads, but are run on the same processor.
However, multithreading is not necessarily improve the performance of programs, for example, your project manager assigned to you, 10 bug so you can change, you should be a one to change, most people will not bug to change every 5 minutes , that change End up, if so, what parts of the last change to remember. The total circumstances in which complicated and did not improve the performance of programs, but because of too much context switching introduces some additional overhead.
Therefore, under a single cpu can only achieve concurrent programs, parallel programs, but can not be achieved.
Now the era of multi-core cpu to, then the emergence of new concepts: parallel.
Is a real fine-grained parallel on the same time; both at the same time point simultaneously with multiple concurrent; more precise and simple terms: that is a program running on each cpu to reach the same point in time each cpu running a program.
Summary, the computer calculation principle is sequential; only one computer at the same time can only complete one operation; since not break this theoretical basis, then based in their development to go: to a computer built Duoge cpu , so that you can achieve true parallel.
For now, the hardware has come the era of multi-cpu, software technology has begun to follow in parallel, such as java has begun to add new virtual machines in parallel. However, the current terms, concurrent programming, or the mainstream. So what the situation continue to use concurrent programming?
For example, you have a calculation, including the calculation of cpu, network transmission, database access, io operation, if you do not use complicated, but single-threaded execution, then the cpu end computing, the program also need to wait for the next steps to complete a thorough be considered as an execution completed. If the process of implementation, but also the arrival of the new access, then wait for the completion of the last of the implementation of complete, to begin this visit. Such a large extent a waste of cpu resources; if concurrent programming using both linear programming, then the process would have described above: the first request is complete cpu calculation, the started to wait for the remaining steps of the implementation; the next requests may also be the first to complete the calculation of cpu, the remaining steps into the state; such a large extent to improve the efficiency of the process, also increased the cpu utilization, cpu full advantage of computing resources.
Therefore, if your program is only for the calculation of the cpu over, then the use of linear programming to more harm than good, because the cpu can only complete one calculation, if the calculation of an ongoing hang, start a new calculation, the new calculation of the half, was again suspended and returned to the previous calculation; we can realistically think about them: a student at the same time, can only do a homework, is currently doing language work, after doing some go, and started doing math, then open the data then have to work this, organize ideas, to find teachers of subjects such as layout, and then started; and then half-done, leaving the remaining languages of the operation started. . . . . . No need to describe anymore, right? So, just cpu calculation procedure does not require multi-threaded. But if the program includes a number of steps, of which a relatively time-consuming step, the program would like to finish one calculation, time-consuming operation to wait to return, this time have to consider the linear programming.
Related Posts of Distinction between the concept of concurrent and parallel
When the number of concurrent users marked the beginning of growth, you may be dissatisfied with a single machine can provide the performance, or because of a single JVM instance gc restrictions, you can not expand your java application, in such circumsta
Today, the use of hibernate in the company encountered a troublesome problem, the use of hibernate when the primary key generation strategy set sequence, but always reported in the implementation could not get next sequence value of the error, then o ...
hibernate lock mechanism 1. Pessimistic lock It refers to the modification of data by outsiders hold a conservative attitude. The assumption that at any time access to data, may also have another client to access the same data, in order to maintain t ...
Concurrent Programming in Java: Design Principles and Patterns (Doug Lea) Concurrent Programming in Java: Design Principles and Patterns, 2nd edition (Doug Lea; Addison-Wesley, 1999 years) Java Concurrent Programming - Design principles and patterns (seco
[Problem] Now, in the development of the so-called multi-storey JavaEE applications, data persistence layer is always essential, and "Automatic" of ORM - Hibernate, and "all-manual-type" of SqlMap - IBatis, equivalent data are Per ...
The use of hibernate, implementation of data persistence. Has the following several processes. One configuration database connection information. Hibernate.config 2 configuration mapping. 3 use: the use of the process are the following steps: 3.1: Ge ...
The origin of ideas are pretty long history of reasons: [Use iBATIS history] The use of iBATIS has been a long time, the system is to use the CRUD template tool to generate the code, although there are tools to generate, but looked at a lot of CRUD the Sq
hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...