I do like this and it works !
It seems that in the first example the EndFlag was passed by value, not by reference...
By the way, is there a method to know when a thread is terminated ? Or wait for it to finish ? In the Pico/MicroPython context...

By the way, is there a method to know when a thread is terminated ? Or wait for it to finish ? In the Pico/MicroPython context...
Code:
import _threadimport timeterminate = Falsedef my_thread(): global terminate print("New thread is running...") while not terminate: time.sleep(0.2) print("New thread is terminating gracefully.") _thread.start_new_thread(my_thread, ())try: while True: time.sleep(2) except KeyboardInterrupt: terminate = True time.sleep(0.3) print("Main thread terminated gracefully.")
Statistics: Posted by Marus780 — Fri Mar 01, 2024 1:33 pm