Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #9115
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <thinke365@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.044 |
| X-Spam-Evidence | '*H*': 0.91; '*S*': 0.00; 'python': 0.08; 'answer?': 0.09; 'concurrency': 0.09; 'subject:problems': 0.09; 'subject:python': 0.12; 'met,': 0.16; 'subject: \n ': 0.16; 't.start()': 0.16; 'threading': 0.16; 'def': 0.16; 'subject:not': 0.21; 'mechanism': 0.22; 'times,': 0.25; 'message- id:@mail.gmail.com': 0.28; 'import': 0.29; "skip:' 30": 0.29; 'subject:?': 0.31; 'print': 0.32; 'to:addr:python-list': 0.34; 'there': 0.34; 'received:74.125.83.174': 0.37; 'received:mail- pv0-f174.google.com': 0.37; 'thread': 0.37; 'some': 0.37; 'but': 0.37; 'received:google.com': 0.38; 'run': 0.39; 'case': 0.39; 'should': 0.39; 'to:addr:python.org': 0.39; 'received:74.125': 0.40; 'total': 0.61; 'subject:program': 0.67; 'special': 0.67; 'why?': 0.73; 'programming?': 0.84; 'subject:any': 0.84; 'subject:face': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=ICh88DgEjSZpwN0lbfjUUQrOGuBOQkdodyBukPVv1mw=; b=SXyOAPjTc0qouXEDq90ggx62kUVGZgVX8hqFvjSuyEpBIFOANjcCo76zrQvRy0Dier dvG58IbVCD5eCL+aZweDnE+KhtRX9e0i8lTYbuY775l7BIBmNT62NBq7vDGk4iosfnGB QNf4vUP/OBw3+rb+Rli3QXi1Dyn7O+CHF3eg0= |
| MIME-Version | 1.0 |
| Date | Sun, 10 Jul 2011 04:45:30 +0800 |
| Subject | why the following python program does not face any concurrency problems without synchronize mechanism? |
| From | smith jack <thinke365@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.803.1310244333.1164.python-list@python.org> (permalink) |
| Lines | 19 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1310244333 news.xs4all.nl 21858 [2001:888:2000:d::a6]:41135 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:9115 |
Show key headers only | View raw
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?
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
why the following python program does not face any concurrency problems without synchronize mechanism? smith jack <thinke365@gmail.com> - 2011-07-10 04:45 +0800 Re: why the following python program does not face any concurrency problems without synchronize mechanism? TheSaint <nobody@nowhere.net.no> - 2011-07-10 22:50 +0800
csiph-web