Process and Thread differences

Source: Internet
Author: User

1. Process (Progress)

  a process is a single execution activity on a computer by a stand-alone program. For example, running the QQ program, running in the MP3 player and so on. A process is started by running a program. Process-based multitasking is the task of allowing a computer to run multiple programs at the same time.

2. Threads (thread)

  A thread is a smaller execution unit than a process and can be understood as a fragment of a program that executes in a process. a thread-based multitasking process is a program that can perform multiple tasks. For example, Thunder download software, when downloading a video from the network, the user can play downloaded video content before it is finished downloading, this is the existence of playing and downloading two threads.

3. Process and Thread differences:

Multiple tasks can be run concurrently in the operating system called multi-process, and multiple execution paths in an application ice method execution is called multithreading. The process and thread differences are as follows:

    • each process has its own code and data space (process context), and the switching overhead between processes is large ;
    • Multiple threads within the same process share the same large code and data space, each process has a separate run stack and program counter (PC), and the switching overhead between threads is small

In general, you may want to use multithreading in the following situations:

    • The program needs to perform two or more tasks at the same time;
    • The program needs to implement some tasks that need to wait, such as user input, file read and write operation, network operation, search, etc.
    • When you need some programs that run in the background.

1. Why do I need multi-threading?

Multithreading is a multitasking concurrency that has the following advantages:

    • Improve the application accordingly;
    • Improve computer CPU utilization;
    • Improve program Structure

Process and Thread differences

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.