【发布时间】:2014-07-01 00:15:22
【问题描述】:
我希望在我的应用程序中使用多处理或线程来在后台执行一些耗时的操作。我看过很多例子,但我仍然无法实现我想要的。我正在尝试加载一堆图像,每个图像都需要几秒钟。我希望加载第一个图像,然后让其他图像在后台加载并存储在列表中(以供稍后使用),同时程序仍在执行其他操作(例如允许我的 GUI 上的控件仍然工作)。如果我有类似下面的示例,我该怎么做?我应该使用多处理还是线程?
class myClass():
def __init__(self, arg1, arg2):
#initializes some parameters
def aFunction(self):
#does some things
#creates multiple processes or threads that each call interestingFunc
#continues doing things
def interestingFunc(self):
#performs operations
m = myClass()
【问题讨论】:
标签: python multithreading multiprocessing