Liunx system processes and threads

Source: Internet
Author: User

Hello, everyone. Today, when I saw the word "Single-thread" in high-performance mysql, I instantly circled it. What is the thread? What is a thread?

Needless to say, I am very familiar with the process. What is the relationship between them? I looked for some information and saw an image metaphor on Baidu. Then I summed up a more vivid metaphor.

Generally, a process consists of at least one thread, one main thread, and other threads. Multiple Threads aim to share the CPU time slice to complete parallel tasks.

A thread is the unit of CPU allocation time. Each thread corresponds to a function in the process, that is, a code segment in the memory. When multiple threads are executed, the CPU allocates time based on their priority, enable them to complete their functions.

To put it simply, a process is an active program, a container, and a thread runs in a process container. It is the code that actually executes the work.

The image of Baidu netizens is as follows:

The sandbox is used as an example to describe. A process is like a sandbox. The thread is like a child in the sandbox. The children ran around in the sandbox, and may drag the sand into the eyes of other children. They would kick each other or bite each other. However, the difference between these sandboxes is that each sandbox is completely composed of walls.
Close to the ceiling, no matter how hard the children in the box are, they will not affect other children in the sandbox. Therefore, each process is like a protected sandbox. No one can go in or out without permission.

I thought about it later, and I asked a question about the real name of the boss studying java ),My image metaphor:

My understanding: single thread mode)

Process as a road.

The thread is imagined as a car on the road.

If there are two programs running, there will be two roads. Their destination is memory, and the cars on each road can run in disorder, but it will not affect the cars on other runways, however, what the two of them do is to requisition resources to grab memory resources. In fact, there is a priority here.

AndThe execution sequence of a program.

Connection --> session --> process --> thread

I don't know if you can understand what you want to express. This is abstract and you need to think about it.

This article is from the "history_xcy" blog, please be sure to keep this

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: 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.