Get rid of the lock; it's no longer needed.
This commit is contained in:
parent
0dd010a9e4
commit
7e0e9555b7
|
@ -16,25 +16,15 @@ FILL = 'red'
|
||||||
|
|
||||||
stop = 0 # Set when main loop exits
|
stop = 0 # Set when main loop exits
|
||||||
|
|
||||||
lock = threading.Lock() # Protects the random generator
|
|
||||||
|
|
||||||
def particle(canvas):
|
def particle(canvas):
|
||||||
r = RADIUS
|
r = RADIUS
|
||||||
lock.acquire()
|
x = random.gauss(WIDTH/2.0, SIGMA)
|
||||||
try:
|
y = random.gauss(HEIGHT/2.0, SIGMA)
|
||||||
x = random.gauss(WIDTH/2.0, SIGMA)
|
|
||||||
y = random.gauss(HEIGHT/2.0, SIGMA)
|
|
||||||
finally:
|
|
||||||
lock.release()
|
|
||||||
p = canvas.create_oval(x-r, y-r, x+r, y+r, fill=FILL)
|
p = canvas.create_oval(x-r, y-r, x+r, y+r, fill=FILL)
|
||||||
while not stop:
|
while not stop:
|
||||||
lock.acquire()
|
dx = random.gauss(0, BUZZ)
|
||||||
try:
|
dy = random.gauss(0, BUZZ)
|
||||||
dx = random.gauss(0, BUZZ)
|
dt = random.expovariate(LAMBDA)
|
||||||
dy = random.gauss(0, BUZZ)
|
|
||||||
dt = random.expovariate(LAMBDA)
|
|
||||||
finally:
|
|
||||||
lock.release()
|
|
||||||
try:
|
try:
|
||||||
canvas.move(p, dx, dy)
|
canvas.move(p, dx, dy)
|
||||||
except TclError:
|
except TclError:
|
||||||
|
|
Loading…
Reference in New Issue