Objective
Time is a Kill a pig knife, the years are relentless in my handsome face left traces! Hate, this is the beginning of my social journey. 2015 Shanghai, in the hook net to the iOS internship, two interviews! In the interview was not clear of the blow, where the sad is not one by one. In school when the study is not serious, study time and no notes, knowledge in the actual project practice, the final result is what all know have heard, but the specific what can not say! So resolutely decided to devote to the blog of the big team, with you to encourage each other.
PS: Since it is a social journey, in addition to the technology of the stepping stone, of course, there is a man! I can only say I was brushed by HR)
Long Talk (Process and Thread)
As a senior rookie-level fresh graduates, I would like to all of you if this article includes all the articles will be "original"------that is impossible, is the original plus reference ~ ~ (in fact, is "plagiarism", I believe that the graduation thesis of the children's shoes are body + "deep" have experience! )
First of all to talk about process (the legendary process) and thread (the legendary thread), do not know whether you have found that the Chinese course and thread is very confusing (TMD is the difference of the word), but when you foreign flavor with the process and thread to read them You're going to ask, "they" have a half-dime relationship, and it does matter! Can only say that big Chinese really is very interesting, English not the "bird" to our big Chinese compromise, because all the new technology is the English version of the beginning, do not deny! Swift just came out with the English version only. Although I am also "level four" floating slag slag!
Process VS Thread
Reference address:http://www.programmerinterview.com/index.php/operating-systems/thread-vs-process/
Process: A process is an executing instance of A application.
A process is an instance of the app running (executing)
Thread: A thread is a path of execution within a process.
A thread is a running (execute) path in a process.
See here I am a bit like spit trough under the textbook God Horse, the heavenly book AH has wood! Readers, do not scold me from the fawning 650) this.width=650, "src=" Http://img.baidu.com/hi/jx2/j_0021.gif "alt=" J_0021.gif "/>.
When an app starts or runs, it creates a process in the operation system (operating system), and the Windows classmate opens your task Manager (Task Manager) See how many processes you have already run QQ? How many threads are there? With the classmate of the Mac to open your activity Monitor, I use mac503 five years ago product, the accompanying drawings are as follows: 650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/5B /50/wkiom1ufoqezatdjaaxlw9ly1be834.jpg "title=" screen Shot 2015-03-15 at 11.09.54 pm.png "alt=" Wkiom1ufoqezatdjaaxlw9ly1be834.jpg "/>
You see our big qq,qq in Activity Monitor is just a process in the Mac running all processes, and QQ has 9 threads. This perfectly interprets the concept of process and thread (thread).
Let's talk about the relationship between the process and the thread, and what's the difference between them?
First English version of: (Reference address: Ibid.)
1. threads are easier to create than processes since they Don ' t require a separate address space.2. multithreading requires Careful programming since threads share data strucures that should only be modified by one threadat a time. Unlike Threads, processes don ' T share the same address space.3. threads are considered lightweight because they use far less resources than processes.4. processes are independent of each other. Threads, since they share the same address space are interdependent, so caution must be taken so that different Threads don ' T STEP ON&Nbsp;each other. this is really another way of stating #2 above.5. a process can consist of multiple threads.
1. Because creating a process requires allocating a single piece of address space (or memory space), and thread is the path that is executed in the process, the address space (memory space) used by the thread is the space of the process, and no additional memory is required to create the thread. So thread creation is easier than process.
2, the original translation: Because the threads share the same data structure, at the same time only by one thread to modify the data structures, multithreaded programming needs to be very careful, and for the process is not to worry about, because the process has its own separate address space.
Insight: Because threads share the same data structure, once there is a lot of threads, there is a confusion about the thread's modification. So in multithreaded programming must be clear-minded.
3. The original translation: threads are considered lightweight because threads require much less resources than processes.
Opinion: In the text of the article there is a sentence like this, I also quite agree:It's important to note that a thread can do anything a process can does. it is necessary to point out that threads can do The process can do anything. We can understand that the process is Goku, the thread is the one who is Goku. Wukong can do Wu empty capable things, but Fen is the strength of the limited, so can be considered lightweight, and Goku himself is a lot more, so is considered to be heavyweight (heavyweight).
4, the original translation: The process is independent of each other, and the threads are shared between the same address space, so it is not independent between the threads. So be careful with the "stepping" between threads (working on an object at the same time).
5, the original translation: a process can be composed of multiple threads.
PS: The first time to write a blog, the bad place to welcome the Spit Groove! Due to the operating system knowledge forgotten almost, another day must be mended!
This article is from the "9726972" blog, please be sure to keep this source http://9736972.blog.51cto.com/9726972/1620723
IOS Multithreading long Talk (Process and Thread)