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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:05:19+00:00 2026-05-17T22:05:19+00:00

One of the main purposes of writing code in the asynchronous programming model (more

  • 0

One of the main purposes of writing code in the asynchronous programming model (more specifically – using callbacks instead of blocking the thread) is to minimize the number of blocking threads in the system.

For running threads , this goal is obvious, because of context switches and synchronization costs.

But what about blocked threads? why is it so important to reduce their number?

For example, when waiting for a response from a web server a thread is blocked and doesn’t take-up any CPU time and does not participate in any context switch.

So my question is:
other than RAM (about 1MB per thread ?) What other resources do blocked threads take-up?

And another more subjective question:
In what cases will this cost really justify the hassle of writing asynchronous code (the price could be, for example, splitting your nice coherent method to lots of beginXXX and EndXXX methods, and moving parameters and local variables to be class fields).

UPDATE – additional reasons I didn’t mention or didn’t give enough weight to:

  1. More threads means more locking on communal resources

  2. More threads means more creation and disposing of threads which is expensive

  3. The system can definitely run-out of threads/RAM and then stop servicing clients (in a web server scenario this can actually bring down the service)

  • 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-17T22:05:20+00:00Added an answer on May 17, 2026 at 10:05 pm

    So my question is: other than RAM (about 1MB per thread ?) What other resources do blocked threads take-up?

    This is one of the largest ones. That being said, there’s a reason that the ThreadPool in .NET allows so many threads per core – in 3.5 the default was 250 worker threads per core in the system. (In .NET 4, it depends on system information such as virtual address size, platform, etc. – there isn’t a fixed default now.) Threads, especially blocked threads, really aren’t that expensive…

    However, I would say, from a code management standpoint, it’s worth reducing the number of blocked threads. Every blocked thread is an operation that should, at some point, return and become unblocked. Having many of these means you have quite a complicated set of code to manage. Keeping this number reduced will help keep the code base simpler – and more maintainable.

    And another more subjective question: In what cases will this cost really justify the hassle of writing asynchronous code (the price could be, for example, splitting your nice coherent method to lots of beginXXX and EndXXX methods, and moving parameters and local variables to be class fields).

    Right now, it’s often a pain. It depends a lot on the scenario. The Task<T> class in .NET 4 dratically improves this for many scenarios, however. Using the TPL, it’s much less painful than it was previously using the APM (BeginXXX/EndXXX) or even the EAP.

    This is why the language designers are putting so much effort into improving this situation in the future. Their goals are to make async code much simpler to write, in order to allow it to be used more frequently.

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

Sidebar

Related Questions

We are factoring out the common code from our Perl project. One main program
I have a WinForms TreeView with one main node and several sub-nodes. How can
How would I run both of them under one main website, say www.example.com, which
With a distributed application, where you have lots of clients and one main server,
I have a web project that I developed where one of the main functions
Which one performs better to run a game main loop?
When I have one app.config in my main project I always have to duplicate
What is the main difference between int.Parse() and Convert.ToInt32() ? Which one is to
We are currently working on a new version of our main application. one thing
One of those classic programming interview questions... You are given two marbles, and told

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.