.net - Why is creating a new thread expensive? -


i read lots of .net resources telling me should using thread pool thread rather instantiating new thread myself. should because instantiating new thread expensive operation. happens during thread creation makes expensive operation?

everything relative. creating new thread expensive... relative not creating one. if you're not doing lot of work per thread, work involved in building , tearing down threads can potentially make measurable portion of cpu time. it's cheap relative creating new process, on windows.

it's better use threadpool because tuned avoid having many threads active @ once. want more handful of threads active @ 1 time, or you'll spend lot of cpu time performing context-switches between them all. using threadpool manages you, additional requests queued until worker thread ready.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -