def parent() while truei + _thread start_new_thread(child( ,)if input(=' 'break parent(this script really contains only two thread-specific linesthe import of the _thread module and the thread creation call to start threadwe simply call the _thread start_new_thread functionno matter what platform we're programming on +this call takes function (or other callableobject and an arguments tuple and starts new thread to execute call to the passed function with the passed arguments it' almost like python' function(*argscall syntaxand similarly accepts an optional keyword arguments dictionarytoobut in this case the function call begins running in parallel with the rest of the program operationally speakingthe _thread start_new_thread call itself returns immediately with no useful valueand the thread it spawns silently exits when the function being run returns (the return value of the threaded function call is simply ignoredmoreoverif function run in thread raises an uncaught exceptiona stack trace is printed and the thread exitsbut the rest of the program continues with the _thread modulethe entire program exits silently on most platforms when the main thread does (though as we'll see laterthe threading module may require special handling if child threads are still runningin practicethoughit' almost trivial to use threads in python script let' run this program to launch few threadswe can run it on both unix-like platforms and windows this timebecause threads are more portable than process forks--here it is spawning threads on windowsc:\pp \system\threadspython thread py hello from thread hello from thread hello from thread hello from thread +the _thread examples in this book now all use start_new_thread this call is also available as thread start_new for historical reasonsbut this synonym may be removed in future python release as of python both names are still availablebut the help documentation for start_new claims that it is obsoletein other wordsyou should probably prefer the other if you care about the future (and this book must! parallel system tools