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

  • Home
  • SEARCH
  • 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 8814955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:15:24+00:00 2026-06-14T04:15:24+00:00

I come across with such code in many places in a project written by

  • 0

I come across with such code in many places in a project written by others, and I am still puzzled why somebody would write such code.

Consider the following code (this code is in C# but I think it applies to many languages too – possibly just with difference on syntax or maybe names of the classes and the way of doing this – you get the idea.):

Thread thread;

thread = new Thread(new ThreadStart(method));
thread.Start();
thread.Join();

To my understanding, this code means start a thread and runs method, and then this thread wait, without doing any other things, for the newly started thread to finish.

If it is the case, why I don’t just call the method directly, i.e.

method()

Could anyone explain to me if my understanding is right or not? Does the first code fragment does functionally the same as the second?

  • 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-14T04:15:25+00:00Added an answer on June 14, 2026 at 4:15 am

    usually, you’re right, this is not a very useful thing to do.

    But sometimes, you may want an operation to run on a separate thread, because it modifies or depends on some per-thread state.

    The function may be fiddling with thread-local data, or it might call out into native COM code, and COM’s threading apartment stuff is initialized on a per-thread basis, so to avoid this being affected by changes in the calling code, you may want to just spin off a new thread to call the function on.

    Of course, in such cases, a small code comment explaining why something so apparently useless is being done, would probably be a good idea. 😉

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

Sidebar

Related Questions

I've come across such code which I need to re-write using ANSI Standard and
Sometimes I come across code such as this: import matplotlib.pyplot as plt x =
From time to time you come across some interesting code or programming challenges, such
I come across the google project http://www.20thingsilearned.com/ today and I found the canvas-based page
I come across this code in my web.xml but I don't understand what it
I come across some code where a LPCTSTR is assigend to a _bstr_t. As
I've come across code that looks like this: NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:1024
I’m looking at some C# code, and have come across the following statement: #if
Ok so I'm working away on a project in Nodes, and I've come across
I've come across many programming languages. Each of them had their charm, but also

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.