Python 运行 同一个函数在不知道需要多少个实例的情况下实时使用不同的参数多次

Python run the same function several times with various arguments in realtime without knowing how many instances are required

import time
import threading
import ctypes

def fun1(txt):
  return ctypes.windll.user32.MessageBoxW(0, txt, "title", 0)

t1 = threading.Thread(target=fun1, args=("1"))
t2 = threading.Thread(target=fun1, args=("2"))
t3 = threading.Thread(target=fun1, args=("3"))

t1.start()
t2.start()
t3.start()

我有这段代码,效果很好,但我不希望它仅限于三个实例,在调用时,我想要一些可以实时处理任意数量实例的东西。

感谢任何指导,提前致谢。

import threading
import ctypes

def func(*args, **kwArg):
    func2(f)

def func2(f):
    ctypes.windll.user32.MessageBoxW(0, f, "Title", 0)

if __name__ == '__main__':
    threads = []

    fruits = ['apple', 'banana', 'cherry']
    for f in fruits:
        t = threading.Thread(target=func, args=(f))  
        t.start()
        threads.append(t)

    for t in threads:
        t.join()