Apr-22-2017, 05:21 PM
The easiest way is to define a function that will be the core of your thread, then create threads that will call this function and pass it different arguments (names in example below, graph number for you):
import threading,time,random RUNS=4 THREADNAMES=['ONE','TWO','THREE'] def threadFunction(id): print "Starting thread %s" % id for _ in range(RUNS): time.sleep(random.uniform(.5,2.5)) print 'Thread %s still alive' % id print "Ending thread %s" % id # create the threads threads=[threading.Thread(target=threadFunction,args=(id,)) for id in THREADNAMES] # make them run for t in threads: t.start() # make sure they are all ended before existing: for t in threads: t.join()However, due to the Global Interpreter Lock there is no real concurrent execution of threads in Python, so you won't run on more core with Python threading.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Your one-stop place for all your GIMP needs: gimp-forum.net