extending the thread class the output from this isstarting done note that it is common to call any subclasses of the thread classsomethingthreadto make it clear that it is subclass of the thread class and should be treated as if it was thread (which of course it is daemon threads thread can be marked as daemon thread by setting the daemon property to true either in the constructor or later via the accessor property for examplefrom threading import thread from time import sleep def worker(msg)for in range( )print(msgend=''flush=truesleep( print('starting'create daemon thread thread(daemon=truetarget=workerargs=' ' start(sleep( print('done'this creates background daemon thread that will run the function worker(such threads are often used for house keeping tasks (such as background data backups etc as mentioned above daemon thread is not enough on its own to keep the current program from terminating this means that the daemon thread will keep looping until the main thread finishes as the main thread sleeps for that allows the daemon thread to print out about strings before the main thread terminates this is illustrated by the output belowstarting cccccdone