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 5970955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:26:55+00:00 2026-05-22T20:26:55+00:00

Is it possible, and is there a code example. On how to make multiple

  • 0

Is it possible, and is there a code example. On how to make multiple instances of a single thread.

a quick example is just

Thread foo = new Thread(testThread);

foo.Start(); // but start more than once instance

@Andrew
Well, when using a web client to download a page it takes about 0.5 seconds. When I make multiple threads that do the same task (copy and pasting the same thread under different function names and running them simultaneously using a global list and indexer for the for loop. With 4 copy threads it gets a page downloaded at about 0.15 seconds.

3 times faster from 4 threads is nice but I want a more clean 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-05-22T20:26:56+00:00Added an answer on May 22, 2026 at 8:26 pm

    The thread instance is not the same as the thread logic. So you can create multiple threads using the same method, you don’t have to copy-and-paste the code into separate identical ones:

    for( int i=0; i<4; i++ )
        (new Thread(threadProc)).Start();
    

    This is legal and may do what you need — but per the comments, if you do need parallelism then it would be wiser to use the ThreadPool or else use TPL Tasks:

    for( int i=0; i<4; i++ )
        ThreadPool.QueueUserWorkItem(threadProc);
    
    for( int i=0; i<4; i++ )
        (new Task( threadProc )).Start();
    

    These variations can save you the overhead of creating and destroying individual threads and can achieve better overall utilization.

    All these approaches have variations where you can pass parameters to your function, for example the variable i or other information to divide the work. See the docs for details, e.g. http://msdn.microsoft.com/en-us/library/kbf0f1ct.aspx

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

Sidebar

Related Questions

For example, given the following code, how is it possible to make the string
Hi there is possible to set a default language or set a new one
Possible duplicate question: Is there a way to indefinitely pause a thread? In my
Possible Duplicate: Is there some ninja trick to make a variable constant after its
I was wondering ( if possible ) if there was a program/tool/utility that when
Is there a possible htaccess directive that can transparently forward request from index.php to
Possible Duplicate: Is there a tool that can display a SVN repository visually (
Possible Duplicates: Is there a problem that has only a recursive solution? Can every
Is there any possible way to PLAY a you tube video on page load
Is there any possible way to apply more than CSS to a control through

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.