Skip to content

Instantly share code, notes, and snippets.

@hedcler
Created December 19, 2019 19:23
Show Gist options
  • Select an option

  • Save hedcler/d3564abc820e5ad9839c734d932db3b5 to your computer and use it in GitHub Desktop.

Select an option

Save hedcler/d3564abc820e5ad9839c734d932db3b5 to your computer and use it in GitHub Desktop.

Revisions

  1. hedcler created this gist Dec 19, 2019.
    27 changes: 27 additions & 0 deletions Python Threads
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    without join:
    +---+---+------------------ main-thread
    | |
    | +........... child-thread(short)
    +.................................. child-thread(long)

    with join
    +---+---+------------------***********+### main-thread
    | | |
    | +...........join() | child-thread(short)
    +......................join()...... child-thread(long)

    with join and daemon thread
    +-+--+---+------------------***********+### parent-thread
    | | | |
    | | +...........join() | child-thread(short)
    | +......................join()...... child-thread(long)
    +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, child-thread(long + daemonized)

    '-' main-thread/parent-thread/main-program execution
    '.' child-thread execution
    '#' optional parent-thread execution after join()-blocked parent-thread could
    continue
    '*' main-thread 'sleeping' in join-method, waiting for child-thread to finish
    ',' daemonized thread - 'ignores' lifetime of other threads;
    terminates when main-programs exits; is normally meant for
    join-independent tasks