In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Multithreaded vs multiprocess program: a pile of code is stored in a document process in the form of text: a state in which the program runs includes address space, memory, data stack, etc. Each process completes an independent running environment by itself, and multi-process sharing data is an independent running segment of a problem thread and a process. A process can have multiple threads lightweight a process sharing data and context among multiple threads of a process sharing mutual exclusion global interpretation lock (GIL) the execution of python code is controlled by the python virtual machine in the main loop there is a control thread in the use of executing threading directly using threading.Thread to generate Thread examples t = threading.Thread (target=xxx, args= (xxx) ) t.start (): start multithreaded t.join (): wait for the completion of multithreaded execution case 01:
Import threading
Import time
Def loop01 (in01):
Print ("start loop01 at: {0}" .format (time.ctime ()
Print ("loop01 parameter: {0}" .format (in01))
Time.sleep (4)
Print ("end loop01 at: {0}" .format (time.ctime ()
Def loop02 (in01, in02):
Print ('start loop02 at: {0}' .format (time.ctime ()
Print ("loop02 parameter, first parameter {0}, second parameter {1}" .format (in01,in02))
Time.sleep (2)
Print ("end loop02 at: {0}" .format (time.ctime ()
If name = 'main':
Print ("Starting at: {0}" .format (time.ctime ()
T1 = threading.Thread (target=loop01,args= ("loop01 parameter",))
T2 = threading.Thread (target=loop02,args= ("loop02 parameter 1", "loop02 parameter 2"))
T1.start ()
T2.start ()
T1.join ()
T2.join ()
Print ("All done at {0}" .format (time.ctime ()
While True:
Time.sleep (10)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.