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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:05:49+00:00 2026-06-13T12:05:49+00:00

Windows 7, Intel CORE i3, 64 bit, RAM 4Gb, 2.27 GHz .NET Framework 4.0

  • 0

Windows 7, Intel CORE i3, 64 bit, RAM 4Gb, 2.27 GHz
.NET Framework 4.0

I have the following code:

static void Main(string[] args)
{
    var timer = new Stopwatch();
    timer.Start();

    for (int i = 0; i < 0xFFF; ++i)
    {
        // I use one of the following line at time
        Task.Factory.StartNew(() => { });
        new Thread(() => { }).Start();
    }

    timer.Stop();

    Console.WriteLine(timer.Elapsed.TotalSeconds);
    Console.ReadLine();
}

If I use Task the output is always less then 0.01 seconds, but if I use Thread the output is always greater than 40 seconds!
How is it possible? Why so much difference?

  • 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-13T12:05:50+00:00Added an answer on June 13, 2026 at 12:05 pm

    The two are not the same.

    When you use Task.Factory.StartNew, you’re scheduling a task to run on the ThreadPool. When you make a new Thread, you’re having to create and start a new thread.

    In the first case, the threads are already created and reused. This causes the overhead of scheduling the tasks to be far lower, as the threads don’t have to be created each iteration.

    Note that the behavior is not the same, however. When creating a separate thread, each task is getting it’s own thread. They will all get started right away. When using Task.Factory.StartNew, they’re put into the scheduler to run on the ThreadPool, which will (potentially) limit the number of concurrent threads started. This is usually a good thing, as it prevents overthreading from occurring.

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

Sidebar

Related Questions

I have a PC with following specs Windows XP SP3 Intel Core 2 Duo
I have a intel core i3 (not the 2nd generation i3) processor and windows
Windows form application(.Net 3.5) I have a textbox and a button on the form.
windows.h is included, code: #include <windows.h> int main() { HANDLE hToken; DWORD dwSize; TOKEN_ELEVATION_TYPE
I have Windows Vista 64-bit SP2. I am trying to use wxPython for GUI
I'm running a Windows 7 Enterprise, 64bit, Core i5 with 8GB of RAM and
I am running same code on unix (its a cluster) and on windows (intel
I'm trying the following Java code to shut down Windows operating system. I'm using
I am new to spring and have been following the tutorials on http://viralpatel.net and
I want to go for Windows 7 + Intel SSD drives to speed up

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.