bonjour à tous,

voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 
import time
import threading
from threading import Thread, RLock
 
verrou= threading.Lock()
 
class Point(threading.Thread):
 
    result = 0
    def __init__(self,duree,x,y):
        threading.Thread.__init__(self)
 
        self.duree = duree 
        self.x = x
        self.y = y
 
 
    def run(self):
        while True:
            verrou.acquire()
            Point.result= self.Calcul()
            verrou.release()
 
 
    def Calcul(self):
        result = self.x + self.y 
        return result
 
 
 
class Affichage(threading.Thread):
 
    def __init__(self):
        threading.Thread.__init__(self)
 
    def run(self):
        while True:
            time.sleep(2)
            verrou.acquire()
            h = Point.result
            verrou.release()
 
            print(h)
 
 
 
p0 = Point(0.5,1,0)
p4 = Affichage()
 
p0.start()
p4.start()
 
p0.join()
p4.join()
comme vous pouvez le voir la class Point possede la variable result , et je suis obligé de l'initialiser car je l'utilise a la class Affichage, mais la variable result = 0 est une variable globale? c'est comme si elle etait dans def __init__(self) ?

merci d'avance pour vos éclaircissement