Source code for AutomateTheBoringStuff.Ch15.P5_threadDemo

"""Thread demo

This program uses :py:mod:`threading` to demonstrate multithreading.

"""

import time
print('Start of program.')


[docs]def takeANap() -> None: """Take a nap Simple 5 second timer using :func:`time.sleep` followed by a 'Wake up!' print statement. Returns: None. Waits 5 seconds, then prints an exclamation. """ time.sleep(5) print('Wake up!')
[docs]def main(): import threading threadObj = threading.Thread(target=takeANap) threadObj.start() print('End of program.')
if __name__ == '__main__': main()