Why do plain .NET console or windows applications have a minumum of 3 threads???

  • Thread starter Thread starter Bob Rock
  • Start date Start date
B

Bob Rock

Hello,

does anyone know why standard .NET console or windows applications
that do nothing start out with a minimum of 3 threads??? Aren't 3
threads far to many for an application that does nothing??? What are
they for??? Any article around that explains their purpose???


Bob Rock
 
Bob Rock said:
does anyone know why standard .NET console or windows applications
that do nothing start out with a minimum of 3 threads??? Aren't 3
threads far to many for an application that does nothing??? What are
they for??? Any article around that explains their purpose???

Well, there's the finalization thread and the main user thread to start
with - that's two off the top of my head. There may well also be
another thread for the GC to monitor memory usage - not sure on that
one. If so, that's explained it all. I wouldn't say that three is
"far" too many anyway - there must be at least one, otherwise no code
would be executing, so at most there are two unnecessary threads, which
is hardly a huge number.

By the way - aren't three question marks after each question also too
many? ;)
 
The first thread (an unmanaged thread), is the thread created by the OS
whenever a new Win32 process is started.
The first thread run's the EE (from mscoree.dll) and creates a new thread to
load the CLR.
The second thread runs the CLR , who initializes a managed runtime
environment (AppDomainsf) or your application to run, and creates the
Finalizer thread, and gives control your managed applications "main"
procedure.
The third thread is the finalizer thread.
Note that when you attach a debugger to your process, you will see a fourth
thread which is an unmanaged thread used to run the debugger.

Willy.
 
Back
Top