One of the main goals of writing code in an asynchronous programming model (more specifically, using callbacks instead of blocking a thread) is to minimize the number of blocking threads in the system.
To start threads, this goal is obvious due to 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, the thread is blocked and does not accept any processor time and does not participate in any context switch.
So my question is: besides RAM (about 1 MB per thread?) What other resources block the thread?
And another more subjective question: In what cases will it really cost to justify the complexity of writing asynchronous code (for example, dividing your good coherent method into many beginXXX and EndXXX methods, and moving parameters and local variables to class fields).
UPDATE - additional reasons why I did not mention or did not attach enough weight:
More threads means more blocking on shared resources
More threads mean more creation and disposal of costly threads
The system can definitely work with threads / RAM and then stop servicing clients (in a web server scenario, this can actually lead to a decrease in service)
rony l
source share