]> granicus.if.org Git - python/commitdiff
Get rid of the lock; it's no longer needed.
authorGuido van Rossum <guido@python.org>
Tue, 30 Jun 1998 17:01:06 +0000 (17:01 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 30 Jun 1998 17:01:06 +0000 (17:01 +0000)
Demo/tkinter/guido/brownian.py

index b08a9561cb42596b28c2e626d3cead63f3ece713..8007f141cb5ddfa4984e4fe2dc3b86cd1d83dcb9 100644 (file)
@@ -16,25 +16,15 @@ FILL = 'red'
 
 stop = 0                                # Set when main loop exits
 
-lock = threading.Lock()                 # Protects the random generator
-
 def particle(canvas):
     r = RADIUS
-    lock.acquire()
-    try:
-        x = random.gauss(WIDTH/2.0, SIGMA)
-        y = random.gauss(HEIGHT/2.0, SIGMA)
-    finally:
-        lock.release()
+    x = random.gauss(WIDTH/2.0, SIGMA)
+    y = random.gauss(HEIGHT/2.0, SIGMA)
     p = canvas.create_oval(x-r, y-r, x+r, y+r, fill=FILL)
     while not stop:
-        lock.acquire()
-        try:
-            dx = random.gauss(0, BUZZ)
-            dy = random.gauss(0, BUZZ)
-            dt = random.expovariate(LAMBDA)
-        finally:
-            lock.release()
+        dx = random.gauss(0, BUZZ)
+        dy = random.gauss(0, BUZZ)
+        dt = random.expovariate(LAMBDA)
         try:
             canvas.move(p, dx, dy)
         except TclError: