I believe that we often hear about processes and threads. Of course, this must be useful.
What is a process?
Books are processes. You will find that my computer runs multiple processes.
For previous single-core computers (it can only execute one process at a time. Why can we listen to songs and watch movies? It's because the cpu is switching fast !)
Then, for multi-core systems, you can run multiple processes at the same time.
As mentioned above, the memory between processes is independent of each other!
The following describes the thread:
The thread is the minimum Execution Unit of the process. This is a little professional, or a simple figure.
I have read more code!
Main (}
// This code is obviously completed in a single thread!
The following figure illustrates the problem.
The following is a multi-threaded Execution Code:
Main (Thread thread = Thread (run); thread. Start (); (I =; I <; I ++}
Let's take a look at the execution result! Part, followed by the output
The figure shows that it is not continuously output, and the for in the main method is still executed
You may think that it is the effect of creating a thread. Why is this effect?
See the figure below:
The above is a summary of my work and study. The thread principle calling is mainly reflected in this notebook (opening up a new thread stack memory !)
Of course there are still many shortcomings. Do not ping the shortcomings. Please point out!