What is the difference between a process and a thread?

后端 未结 30 2616
Happy的楠姐
Happy的楠姐 2020-11-22 00:39

What is the technical difference between a process and a thread?

I get the feeling a word like \'process\' is overused and there are also hardware and software threa

30条回答
  •  不要未来只要你来
    2020-11-22 01:08

    To explain more with respect to concurrent programming

    1. A process has a self-contained execution environment. A process generally has a complete, private set of basic run-time resources; in particular, each process has its own memory space.

    2. Threads exist within a process — every process has at least one. Threads share the process's resources, including memory and open files. This makes for efficient, but potentially problematic, communication.

    An example keeping the average person in mind:

    On your computer, open Microsoft Word and a web browser. We call these two processes.

    In Microsoft Word, you type something and it gets automatically saved. Now, you have observed editing and saving happens in parallel - editing on one thread and saving on the other thread.

提交回复
热议问题