Day_6.22python Multithreading

Source: Internet
Author: User
Tags thread class

Zombie Process: Child process end, parent class not end

Orphan process: Parent class process over., child process not finished

Process No. 0 is responsible for running, process 1th is responsible for generating, all orphan process shelters (orphan process: parent process over) 1th process, never end!


#!/usr/bin/env python#!--*--coding:utf-8--*--" "2018-6-22 21:24:13 Multi-threaded learning" "#The first way to use threading is to call the thread class in threading directly fromThreadingImportThreadImport TimedefTest ():Print("--==== drank too much last night, next time drink a little!!!") Time.sleep (1)defMain ():" "Creating Threads" "     forIinchRange (5):        #Create a threadt = Thread (target=test) T.start ()if __name__=='__main__': Main ()#The second way to use a thread is to encapsulate it into a class,ImportThreadingImport TimeclassMyThread1 (Threading. Thread):"""create a class to inherit a multithreaded class"""    defRun (self): forIinchRange (3): Time.sleep (1) msg="I ' m"'@'+STR (1)#The Name property holds the names of the current thread.            Print(msg)if __name__=='__main__': T=MyThread1 () T.start

Day_6.22python Multithreading

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.