What is the difference between a process and a thread?

后端 未结 30 2612
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:02

    Process:

    1. Process is a heavy weight process.
    2. Process is a separate program that has separate memory,data,resources ect.
    3. Process are created using fork() method.
    4. Context switch between the process is time consuming.

    Example:
    Say, opening any browser (mozilla, Chrome, IE). At this point new process will start to execute.

    Threads:

    1. Threads are light weight processes.Threads are bundled inside the process.
    2. Threads have a shared memory,data,resources,files etc.
    3. Threads are created using clone() method.
    4. Context switch between the threads are not much time consuming as Process.

    Example:
    Opening multiple tabs in the browser.

提交回复
热议问题