each process only has one main thread ,right ?

I

iMath

When a program starts up, one thread begins running immediately. This is usually called the main thread of the program ,so each process only has one main thread ,right ?
 
S

Steven D'Aprano

iMath said:
When a program starts up, one thread begins running immediately. This is
usually called the main thread of the program ,so each process only has
one main thread ,right ?

I'm not sure if we should say "each process HAS one main thread" or "each
process IS one main thread", or whether there is in fact a difference. But,
yes, each process is equivalent to a single thread.
 
D

Dave Angel

I'm not sure if we should say "each process HAS one main thread" or "each
process IS one main thread", or whether there is in fact a difference. But,
yes, each process is equivalent to a single thread.

Each process merely starts out as a single thread. If it creates other
threads, they are usually not considered main threads.

OP: But note that if a process is running under a debugger, or an IDE,
that debugger may inject one or more threads into the process.

The only place I now of where we care whether a particular thread in a
process is "the main thread" is with a gui, which usually can only sit
in a single, "main" thread. Any gui-related processing done in other
threads must be done very carefully.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top