FAQ
from threading import Thread

def calc(start, end):
total = 0;
for i in range(start, end + 1):
total += i;
print '----------------------result:', total
return total

t = Thread(target=calc, args=(1,100))
t.start()

I have run this program for many times,and the result is always 5050,
if there is any concurrency problem, the result should not be 5050,
which is never met, anyhow
I mean this program should get the wrong answer at some times, but
this never happens, why?
can concurrency without synchronize mechanism always get the right answer?
any special case in python programming?

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 3 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedJul 9, '11 at 8:45p
activeJul 10, '11 at 2:50p
posts3
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase