threads = for i in rangelentokens threadsappend threadingThreadtarget=use_thread args=tokensisplit----1 tokensisplit----0 for t in threads tstart for t in th
This code creates a list of threads and starts them, then waits for them to finish before continuing execution.
The "tokens" list contains strings with two parts separated by "----": the first part is a message to be printed, and the second part is the name of a file to write the message to.
The "use_thread" function takes two arguments: a message and a filename. It opens the file, writes the message to it, and closes the file.
The code creates a thread for each token in the list. Each thread calls the "use_thread" function with the appropriate message and filename. The threads are then started using the "start" method.
After all the threads have been started, the code waits for them to finish using the "join" method. This ensures that all the threads have completed their work before the program continues execution.
原文地址: https://www.cveoy.top/t/topic/bhRB 著作权归作者所有。请勿转载和采集!