22 February 2012 Vérouiller ou déverouiller un thread en utilisant le concepte d’exclusion mutuelle Thread import thread def compteur(myId, val): for i in range(val): mutex.acquire() import thread def compteur(myId, val): for i in range(val): mutex.acquire() python
22 February 2012 Thread: Exécution parallèle de plusieurs copies d’une même fonction Thread import thread def compteur(myId, val): for i in range(val): print '[%d] => %d'import thread def compteur(myId, val): for i in range(val): print '[%d] => %d' python
22 February 2012 Démarrer un Thread avec la méthode start() Thread import thread import time def print_time(nomThread, delai): """ Afficher la date et l'himport thread import time def print_time(nomThread, delai): """ Afficher la date et l'h python
22 February 2012 Exemple d’utilisation des threads avec ‘Thread Local Storage’ Thread import threading local_T = threading.local( ) print 'Dans le Thread principal, shared_varimport threading local_T = threading.local( ) print 'Dans le Thread principal, shared_var python