Outils pour utilisateurs

Outils du site


raspberry_pi_pico:micropython:threading

Ceci est une ancienne révision du document !


Exemple de code utilisant le multi-threading :

"""
Exemple de threading
On ne peut lancer que deux threads à la fois.
"""
 
from time import sleep
import _thread
 
 
def th1():
    counter = 0
    while True:
        print("OOOOO")
        counter += 1
        sleep(1)
 
def th2():
    counter = 0
    while True:
        print("XXXXX")
        counter += 1
        sleep(1)
 
second_thread = _thread.start_new_thread(th2, ())
th1()
raspberry_pi_pico/micropython/threading.1677481847.txt.gz · Dernière modification : 2023/02/27 08:10 de dan