潇洒郎: python threading 实现线程暂停、恢复、停止功能

结果:

线程暂停、恢复、停止见注释

obj-T1-0

obj-T2-0

main 0

obj-T1-1

obj-T2-1

obj-T2-2

main 1

obj-T1-2

obj-T1-3

obj-T2-3

main 2

obj-T1-4

obj-T2-4

obj-T2-5

obj-T1-5

暂停1        # main 2时暂停线程T1

main 3

obj-T2-6

obj-T1-6     # 暂停线程T1需要时间,此时还未暂停

obj-T2-7

main 4       # 此时线程T1已暂停

obj-T2-8  

obj-T2-9

main 5

obj-T2-10

obj-T2-11


main 6       # main 6时恢复线程T1

obj-T2-12

obj-T2-13

恢复

main 7

obj-T2-14

obj-T1-7     # 此时线程T1已恢复

obj-T2-15

main 8

obj-T1-8

obj-T2-16

obj-T1-9

obj-T2-17

main 9

obj-T1-10

obj-T2-18

obj-T1-11

obj-T2-19

main 10       # main 10时停止线程T1(不可恢复)

obj-T1-12

obj-T2-20

obj-T1-13

obj-T2-21

停止1

main 11      # 此时线程T1已停止

obj-T2-22

obj-T2-23

main 12

obj-T2-24

obj-T2-25

main 13

obj-T2-26

obj-T2-27

main 14

obj-T2-28

obj-T2-29

main 15      # main 15时恢复已停止的线程T1

obj-T2-30

obj-T2-31

恢复

main 16

obj-T2-32

obj-T2-33    # 线程T1无法恢复

main 17

obj-T2-34

obj-T2-35

main 18

obj-T2-36

obj-T2-37

ma

你可能感兴趣的:(python,GUI,应用,Python学习,python,threading暂停,线程暂停,恢复,停止)