Python language Learning (eight) 1.1

Source: Internet
Author: User

Thread module: Partial Bottom

Threading module: High-level, provides synchronization mechanism such as lock

Inherit threading. Thread

Run () method/target = function_name

Join (): suspends the current thread until the called thread ends

Start (): Starts the thread, executes the code in run

Threading.current_thread (): Thread number of the currently running thread

Synchronization mechanism:

Threading. Lock (exclusive lock, exclusive lock)

Threading. Rlock (can be re-entered lock, the same thread can be obtained multiple times)

Threading. Semaphone (semaphore, shared lock, number of shares)

Init_value: Number of shares

Threading.condition (provides a wait mechanism to implement a wait queue)

Wait

Notify, Notify_all

Acquire (): Request a lock

Release (): Releasing the lock

Multiprocessing Module

Multiple Python processes = multiple Gil locks

Inherit multiprocessing. Process

Implementing the Run () method

Join (): suspends the current process until the called process ends

Start (): Starts the process, executes the code in run

Inter-process communication

The memory space of the process is independent of each other

Through multiprocessing. Queue Implementation Communication

Queue.put ()

Queue.get ()

Python language Learning (eight) 1.1

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.