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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:24:27+00:00 2026-05-29T22:24:27+00:00

I have a simple program which starts n threads and create some load on

  • 0

I have a simple program which starts n threads and create some load on each thread.
If i only start one thread, one core gets about 100% load.
If i start one process with 16 threads(which means one thread per core), i only get about 80% load.
If i start 8 processes with 2 threads(which still means one thread per core), i get about 99% load.
I don’t use any locking in this sample.

What is the reason for this behavior?
I understand that the load goes down if there a 100 threads working because the OS has to schedule a lot.
But in this case there are only as many threads as cores.

It is even worse(for me at least).
If i add a simple thread.sleep(0) in my loop, the load with one process and 16 threads increase up to 95%.

Can anyone answer this, or provide a link with more information about this specific topic?

One Process 16 threads

Eight Process 2 threads

One Process 16 threads with thread.sleep(0)

//Sample application which reads the number of threads to be started from Console.ReadLine
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the number of threads to be started");
            int numberOfThreadsToStart;

            string input = Console.ReadLine();

            int.TryParse(input, out numberOfThreadsToStart);
            if(numberOfThreadsToStart < 1)
            {
                Console.WriteLine("No valid number of threads entered. Exit now");
                Thread.Sleep(1500);
                return;
            }

            List<Thread> threadList = new List<Thread>();
            Stopwatch sw = Stopwatch.StartNew();
            for (int i = 0; i < numberOfThreadsToStart; i++)
            {
                Thread workerThread = new Thread(MakeSomeLoad);
                workerThread.Start();
                threadList.Add(workerThread);
            }

            while (true)
            {
                Console.WriteLine("I'm spinning... ");
                Thread.Sleep(2000);
            }
        }

        static void MakeSomeLoad()
        {
            for (int i = 0; i < 100000000; i++)
            {

                for (int j = 0; j < i; j++)
                {
                    //uncomment the following line to increase the load
                    //Thread.Sleep(0);
                    StringBuilder sb = new StringBuilder();
                    sb.Append("hello world" + j);
                }
            }
        }
    }
  • 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-29T22:24:28+00:00Added an answer on May 29, 2026 at 10:24 pm

    Your test looks very GC heavy. If you have 16 threads in one process, the GC will run more in that process, and since the client GC isn’t parallel, this leads to a lower load. i.e. you have 16 garbage producing threads per GC thread.

    On the other hand if you run 8 processes with two threads each, you get only two threads producing garbage for each GC thread, and the GC can work in parallel between those processes.

    If you write a test that produces less garbage, and uses more CPU directly, you will likely get different results.

    (Note that this is only speculation, I didn’t run your test, and since I only have a dual core CPU that would be different from your results anyways)

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

Sidebar

Related Questions

Recently I have gone through with one simple threading program, which leads me some
I have a simple script which is used to start another program. This other
I have been trying to create a simple program with Python which uses OpenCV
I have a simple Delphi program that I'm working on, in which I am
I have a simple program that creates a thread, loops twenty times and then
I have a simple Tray icon program that opens a site using System.Diagnostics.Process.Start(URL) And
I have a simple web.py program to load data. In the server I don't
I have a program (time lapse maker) which has two threads that updates a
I'm attempting to write a function which starts a thread for each contact and
I'm trying to write very simple program which will imitate simple DeadLock, where 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.