#!/usr/bin/python3

import threading
import time

class MonThread (threading.Thread):
    # Cette méthode __init__ est le *constructeur* de la classe.
    def __init__ (self, texte_a_afficher):  # Je peux ajouter d'autres paramètres après self
        # J'initialise self en tant que thread:
        threading.Thread.__init__ (self)

        # Maintenant j'ajoute mes initialisations (en tant que MonThread).  Ce
        # signifie que je peux ajouter des attributs dans self, en initialisant
        # chaque attribut comme :
        #   self.NOMATTRIBUT = EXP
        # Ce suffit à créer des attributs d'instance.
        self.texte_a_afficher = texte_a_afficher

        # Vous pouvez imaginer une ligne «implicite»
        #   return self
        # à la fin du corps.

    # Cette méthode d'instance est appelée dans un nouveau thread, quand l'objet
    # de type MonThread est instantié, et on appelle la méthode start sur
    # l'instance.  Ce n'est pas nécessaire de rédéfinire start.
    def run (self):
        while True:
            time.sleep (1)
            print (self.texte_a_afficher)
