If you want to make a task queue in order , Must be used join, The code is as follows :

'''
Created on Dec 23, 2013 @author: long
'''
import threading
from threading import Thread
import time class Thread1(Thread):
'''
classdocs
''' def __init__(self,thread_name):
'''
Constructor
'''
Thread.__init__(self,name=thread_name) def run(self):
'''
run method
'''
count = 0
while True:
print ('thread--',self.getName(),",count:",count)
time.sleep(0.5)
count = count + 1
if count > 10:
break def main(): for y in range(1, 3):
thread1 = Thread1('longthread' + str(y))
thread1.start()
if thread1.isAlive():
thread1.join() for i in range(50):
print ('main:', i) if __name__ == "__main__":
main()

The result is to first execute a program called 'longthread1', Again 'longthread2', And then the main process , therefore thread1.join() I mean wait thread1 After execution , To execute other threads .

python queue join More articles about

  1. Python Queue and its application in wechat robot

    This article comes from i Chunqiu College , Reprint is strictly prohibited without permission . I plan to update wechat robot recently , The author of the discovery robot improved the code a lot , But it took out sqlite database , You need to design your own database according to your needs , The advice I got from communicating with the author is to prevent the concurrency of messages from causing the number of ...

  2. Python Queue service Python RQ Functions from the __main__ module cannot be processed by workers.

    In the use of Python Queue service Python RQ When the report is wrong : Functions from the __main__ module cannot be processed by workers. reason ...

  3. python in join() How to use the function

    function :string.join() Python There is join() and os.path.join() Two functions , The specific functions are as follows :    join():    Connection string array . The string . Tuples . The elements in the list with the specified word ...

  4. Python in join() Function method

    function :string.join() Python There is join() and os.path.join() Two functions , The specific functions are as follows :    join():    Connection string array . The string . Tuples . The elements in the list with the specified word ...

  5. Python in join Functions and os.path.join usage

    Python There is join and os.path.join() Two functions , The specific functions are as follows : join: Connection string array . The string . Tuples . Elements in the list with the specified characters ( Separator ) The connection generates a new string os.path.jo ...

  6. Python MySQL Join

    chapter Python MySQL introduction Python MySQL Create database Python MySQL Create table Python MySQL Insert table Python MySQL Select Python M ...

  7. ( turn )python in join() Method

    original text :http://blog.csdn.net/weixin_40475396/article/details/78227747 function :string.join() Python There is join() and os. ...

  8. 《python》join、 Daemon 、 lock / Semaphore / event 、 Process queue

    One .multiprocess.process modular 1.join Method Blocking the main process , Wait for the subprocess to finish executing before releasing the block import time import random from multiprocessin ...

  9. python queue Queue

    Queue Queue yes python Thread safe queues in standard libraries (FIFO) Realization , Provides a FIFO data structure for multithreaded programming , That's the queue , Used to transfer information between producer and consumer threads basic FIFO queue clas ...

Random recommendation

  1. JAVA analysis XML Four methods of

    XML file :test.xml <?xml version="1.0" encoding="UTF-8"?> <employees> &l ...

  2. OGG for DB2 i 12.2 Release

    2016-04-15 Oracle Released GoldenGate for DB2 i 12.2.0.1.2, Software can be downloaded from OTN or eDelivery download . This is the first one to aim at DB2 for i Of 12.2 edition . this ...

  3. Learn clojure in Y minutes

    Learn X in Y minutes Where X=clojure Get the code: learnclojure.clj Clojure is a Lisp family languag ...

  4. Linux System view hardware information command Encyclopedia

    There are many commands you can use to see Linux Hardware information on the system . Some commands can only print like CPU And memory, a specific hardware component , Other commands can view information about a variety of hardware components . This tutorial can take you a quick look at a variety of hardware ...

  5. js1 in call and apply Usage of

    js1 in call and apply Usage of е roller  Clear Cake rub  Don LAN ran  Scabies I'm sorry  life  Flutes  Pomfret Bong, etc ざ Take a walk Kuan Bian Zhong Kuai  dizzy  I'm not sure  It's not a grab, it's a slap of the fist, and both of them are hit on the leg bone by the fist  Xu Yanqian countries ...

  6. Oracle Basic application of single line function

    One line function Whole SQL The essence of :select sentence + One line function ( back ) String function The commonly used string processing functions are as follows : No. Function name meaning 1 UPPER(c1)  upper Convert all strings to uppercase 2 LOWE ...

  7. 201621123060《JAVA Programming 》 Learning summary week nine

    1. This week's learning summary 1.1 In the way you like ( Mind mapping or something ) Summarize the related contents of set and generics . 2. Written work The problem set of this assignment 1. List Deletion of specified elements in ( Question set questions ) 1.1 Summary of the experiment . And answer : List to ...

  8. sql precompile &amp; Dynamic statements static statements

    https://www.cnblogs.com/micrari/p/7112781.html https://www.cnblogs.com/MarsDing/p/9871703.html https ...

  9. [leetcode]224. Basic Calculator

    Implement a basic calculator to evaluate a simple expression string. The expression string may conta ...

  10. 《 The finger of the sword offer》 Conclusion 2 The binary tree

    Catalog 17. The substructure of a tree (27ms,5836k) 18. Image of binary tree (38ms) 22. Print binary tree from top to bottom (50ms,5832k) 24. The path of a value in a binary tree (26ms,5728k) 38. Binary tree ...