each process only has one main thread ,right ?

Discussion in 'Python' started by iMath, Feb 6, 2013.

  1. iMath

    iMath Guest

    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 ?
     
    iMath, Feb 6, 2013
    #1
    1. Advertising

  2. 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.


    --
    Steven
     
    Steven D'Aprano, Feb 6, 2013
    #2
    1. Advertising

  3. iMath

    Dave Angel Guest

    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
     
    Dave Angel, Feb 6, 2013
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. news.frontiernet.net
    Replies:
    6
    Views:
    1,163
    news.frontiernet.net
    Apr 16, 2004
  2. Robert Oschler
    Replies:
    1
    Views:
    402
  3. PerlFAQ Server
    Replies:
    0
    Views:
    153
    PerlFAQ Server
    Jan 26, 2011
  4. PerlFAQ Server

    FAQ 6.14 How do I process each word on each line?

    PerlFAQ Server, Apr 8, 2011, in forum: Perl Misc
    Replies:
    0
    Views:
    169
    PerlFAQ Server
    Apr 8, 2011
  5. Cameron Simpson
    Replies:
    0
    Views:
    153
    Cameron Simpson
    Feb 6, 2013
Loading...

Share This Page