A
Alexander Walker
Hello
Is it inefficient to create an application that has many threads that
individually may do a small amount of work over a given period of time as
opposed to an application that has a smaller number of threads that do a larger
amount of work over a given time period
here is an oversimplified example
application 1 has 4 threads
every second each thread makes an http request for a file on a different server
and then saves the file it requested to disk
application 2 has 1 thread
every second the thread makes four http requests for a file to four different
servers one after the other after each request it saves the file to disk
you could say that application 1 and application 2 do the same thing, but they
do it in different ways
how expensive is it to switch between threads?
image application 1 and 2 where doing something other than requesting files,
such as reading or writing from a database or executing some operations on data
I ask this because I have a windows service that creates 4 threads, the number
of threads it creates is variable so in the future it might create more threads
or less threads, each thread performs an operation every second, should I be
concerned about how many threads I'm creating? I think that I should, but I'm
not sure how to determine how many threads is too many
thanks
Alex
Is it inefficient to create an application that has many threads that
individually may do a small amount of work over a given period of time as
opposed to an application that has a smaller number of threads that do a larger
amount of work over a given time period
here is an oversimplified example
application 1 has 4 threads
every second each thread makes an http request for a file on a different server
and then saves the file it requested to disk
application 2 has 1 thread
every second the thread makes four http requests for a file to four different
servers one after the other after each request it saves the file to disk
you could say that application 1 and application 2 do the same thing, but they
do it in different ways
how expensive is it to switch between threads?
image application 1 and 2 where doing something other than requesting files,
such as reading or writing from a database or executing some operations on data
I ask this because I have a windows service that creates 4 threads, the number
of threads it creates is variable so in the future it might create more threads
or less threads, each thread performs an operation every second, should I be
concerned about how many threads I'm creating? I think that I should, but I'm
not sure how to determine how many threads is too many
thanks
Alex