1

Let's say I run a function in a thread that prints a number every 5 seconds, while the main application is running in the background:

import threading

def print_num(x):
    x += 1
    print(x)
    threading.Timer(5.0, print_num, [x]).start()

print_num(0)
main()

How do I close the main application and the thread itself if the number exceeds 100?

Rotareti
  • 41,172
  • 18
  • 102
  • 102

0 Answers0