Skip to main content
added 20 characters in body
Source Link
aurelius
  • 536
  • 2
  • 8
  • 26

I am trying to use Threading in Python, and struggle to kick off two functions at the same time, then wait for both to finish and load returned data into variables in the main code. How can this be achieved?

import threading from threading import Thread Thread(target=func1) Thread(target=func2) #<hold until both threads are done, load returned values>  func1(): #<do something> return(x,y,z) func2(): #<do something> return(a,b,c) Thread(target=func1).start() Thread(target=func2).start() #<hold until both threads are done, load returned values> 

I am trying to use Threading in Python, and struggle to kick off two functions at the same time, then wait for both to finish and load returned data into variables in the main code. How can this be achieved?

import threading from threading import Thread Thread(target=func1) Thread(target=func2) #<hold until both threads are done, load returned values>  func1(): #<do something> return(x,y,z) func2(): #<do something> return(a,b,c) 

I am trying to use Threading in Python, and struggle to kick off two functions at the same time, then wait for both to finish and load returned data into variables in the main code. How can this be achieved?

import threading from threading import Thread func1(): #<do something> return(x,y,z) func2(): #<do something> return(a,b,c) Thread(target=func1).start() Thread(target=func2).start() #<hold until both threads are done, load returned values> 
Source Link
aurelius
  • 536
  • 2
  • 8
  • 26

Threading Python3

I am trying to use Threading in Python, and struggle to kick off two functions at the same time, then wait for both to finish and load returned data into variables in the main code. How can this be achieved?

import threading from threading import Thread Thread(target=func1) Thread(target=func2) #<hold until both threads are done, load returned values> func1(): #<do something> return(x,y,z) func2(): #<do something> return(a,b,c)