Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38281

Re: each process only has one main thread ,right ?

Date 2013-02-06 09:59 -0500
From Dave Angel <d@davea.name>
Subject Re: each process only has one main thread ,right ?
References <f386e44d-af1d-4cc9-aace-db9ad1d426bb@googlegroups.com> <51124411$0$29991$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.1414.1360162775.2939.python-list@python.org> (permalink)

Show all headers | View raw


On 02/06/2013 06:52 AM, Steven D'Aprano wrote:
> iMath wrote:
>
>> 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.
>
>

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.

-- 
DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

each process only has one main thread ,right ? iMath <redstone-cold@163.com> - 2013-02-06 03:23 -0800
  Re: each process only has one main thread ,right ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-06 22:52 +1100
    Re: each process only has one main thread ,right ? Dave Angel <d@davea.name> - 2013-02-06 09:59 -0500

csiph-web