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/nul
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 thi
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 alw