【发布时间】:2018-02-21 15:53:27
【问题描述】:
是否可以在函数内部运行线程(该函数将作为进程运行),如果有多少?
示例如下:
def process_one():
def one():
while True:
print("one")
time.sleep(1)
def two():
while True:
print("two")
time.sleep(1)
def three():
while True:
print("three")
time.sleep(1)
a = Thread(target=one)
b = Thread(target=two)
c = Thread(target=three)
a.start()
b.start()
c.start()
if __name__ == '__main__':
p1 = Process(target=process_one)
p1.start()
【问题讨论】:
标签: multithreading python-3.x function multiprocessing