Re: why the following python program does not face any concurrency problems without synchronize mechanism?

2011-07-10 Thread TheSaint
smith jack wrote: have run this program for many times,and the result is always 5050 You might not need to make it in a multiprocess environment Try it in the python (3) shell tot= 0 for k in range(1,100): ... tot += k ... print(tot) ... And watch the risults. -- goto /dev/null --

why the following python program does not face any concurrency problems without synchronize mechanism?

2011-07-09 Thread smith jack
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

Re: why the following python program does not face any concurrency problems without synchronize mechanism?

2011-07-09 Thread Alexander Kapps
On 09.07.2011 22:45, smith jack wrote: 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