Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8324149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:57:18+00:00 2026-06-08T23:57:18+00:00

t1=threading.Thread(target=self.read()) print("something") t2=threading.Thread(target=self.runChecks(), args=(self,)) self.read runs indefinitely, so the program won’t ever reach the

  • 0
t1=threading.Thread(target=self.read())
print("something")
t2=threading.Thread(target=self.runChecks(), args=(self,))

self.read runs indefinitely, so the program won’t ever reach the print line. How is this possible without calling t1.start()? (Even if I call that, it should start running and go on to the next line, shouldn’t it?)


See also: What does it mean when the parentheses are omitted from a function call (supposing no arguments are necessary)? for a deeper understanding of the bug, and Python Argument Binders for a more general solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T23:57:21+00:00Added an answer on June 8, 2026 at 11:57 pm

    Because of the trailing () on the target=self.read(), you’re running self.read in the wrong thread, the current thread — not the new thread you’re creating — and passing the return value of the self.read call as the target argument of Thread. Thread expects to be passed a function to call, so just remove the parentheses and remember to start the thread:

    t1=threading.Thread(target=self.read)
    t1.start()
    print("something")
    

    For targets that need arguments, you can use the args and kwargs arguments to threading.Thread, or you can use a lambda. For example, to run f(a, b, x=c) in a thread, you could use

    thread = threading.Thread(target=f, args=(a, b), kwargs={'x': c})
    

    or

    thread = threading.Thread(target=lambda: f(a, b, x=c))
    

    though watch out if you pick the lambda – the lambda will look up f, a, b, and c at time of use, not when the lambda is defined, so you may get unexpected results if you reassign any of those variables before the thread is scheduled (which could take arbitrarily long, even if you call start immediately).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

just as the sample code shows: for temp in range(0, 10): thread = threading.Thread(target
globalnum = 0 n = 1 class T( threading.Thread ): def run( self ):
The following function System.Threading.Thread.Sleep(); delay the thread in millisecond, and take the integer value
I want to dynamically add threading.Thread classes to a thread queue based on a
I'm trying to create a new System.Threading.Thread object using Jscript, but I can't get
I am a threading noob and I am trying to write a custom thread
I'm simulating some threading in a Windows Service, and the Thread.Start routine for each
I have created an multi thread application on IIS (ASP.NET MVC), When the threading
How to kill the thread? ..... How to restart them again in multi threading?
So, according to MSDN , System.Threading.Timer calls it's callback delegate on a ThreadPool thread.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.