Information isolation in the Python programming thread! It's called python!.

Source: Internet
Author: User

Hello everyone, 并发编程 go to the third article.

The first day of work, we should be more busy. Xiao Ming also, so today's content is very few. It will take just a few minutes to finish the study.

Yesterday we said that the execution of the control program is through message communication between the thread and the thread.

Finish the message communication, today to discuss how the downline thread 信息隔离 is done.

Note to everyone:

信息隔离, this is not the official name of the noun, nor is it widely circulated on the Internet. I was created for the convenience of understanding, you know the better.

Directory of this document

    • Preliminary understanding of information segregation

    • What is the meaning of information isolation

. Preliminary understanding of information segregation

What's that 信息隔离 ?

For example, we have two threads, variables in thread A, and variable values in thread B cannot be shared. This is 信息隔离 .

You might say that the variable name is different.

Yes, if all the threads are not the same object instantiated by a class, it is indeed possible. We'll hang on to this question for the moment, I'll explain later.

So, how do we do that 信息隔离 ?

In Python, which provides threading.local this class, it is convenient to control the isolation of variables, even if the same variable, in different threads, its value is not shared.

Look in the code.

Friendly reminder:

The following code, to understand, may require you to understand the network programming related content of the socket. I have published a related article in the previous few days articles, the students who have no foundation can go to see the article first.

You can also take a look at this programmer's blog OH

Welcome everyone to join million people Exchange Group: 125240963

Information isolation in the Python programming thread! It's called python!.

Related Article

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.