pass variable to thread target

dRecieved = connFile.readline()
processThread = threading.Thread(target=processLine, args=(dRecieved,))  # <- note extra ','
processThread.start()

3.89
9
Scimax 90 points

                                    from threading import Thread
from time import sleep
def run(name):
    for x in range(10):
        print(&quot;helo &quot;+name)
        sleep(1)
def run1():
    for x in range(10):
        print(&quot;hi&quot;)
        sleep(1)
T=Thread(target=run,args=(&quot;Ayla&quot;,))
T1=Thread(target=run1)
T.start()
sleep(0.2)
T1.start()
T.join()
T1.join()
print(&quot;Bye&quot;)

3.89 (9 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
how to pass variable into a thread pass variable to new Thread how to pass variables to target function threading pass argument to thread python how to pass parameter to python thread python thread with parameters multithreading parameters python python multiple thread with parameters target args for for parameter how to pass argument into thread python string how to pass argument into thread python Thread args python thread too many arguments python threading thread start pass arguments call python threading for method that has no parameters python pass arg to thread python single parameter function in thread python make a new thread with different parameters args in threading.thread args threading python threading.Thread(target=thread_function, args=(1,)) python threading pass arguments python3 start new thread arguments threading.thread args python thread pass argument python new thread argument python thread parameters thereading.thread no args how to pass arguments to thread function in python tkreading python function with aguments python pass arguments in a thread python get current threads and arguements python check threads and check arguements python threading example with arguments threading.thread arguments python therad args python provide arguments to threaded function python threading.thread args threading.thread pass arguments thredding args threding python args python thread args tuple python passing keywords to a thread how to pass arguments to thread in python python pass argument to thread
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source