thread.run()有效,但thread.start()在python中不起作用

时间:2018-12-14 12:38:15

标签: python multithreading pygame

我正在为我的项目使用pygame库。 callGUI函数创建一个GUI窗口。 a是用于测试的功能,它每秒打印一次“ 1”。但是,当通过callGUI执行thread.start()时,在打印'123'时不会打印'a'。这意味着该函数不会超出第11行。但是,如果我通过thread.run()执行了此函数(这意味着该函数不再是线程),则一切正常。有什么问题吗?

import socket
from gui import *
import threading
import pygame
from time import *


def callGUI():

    print(123)
    screen = pygame.display.set_mode((1000, 600))
    print('a')
    pygame.display.set_caption('Blue Brick')
    print(1111)


def a():

    while True:
        sleep(1)
        print(111)

call = threading.Thread(target=callGUI)
aa = threading.Thread(target=a)
aa.start()

call.run()

0 个答案:

没有答案