<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 23, 2013 at 11:41 AM, Vittorio Spina <span dir="ltr"><<a href="mailto:vspina@team-italia.it" target="_blank">vspina@team-italia.it</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">quindi in pratica un ciclo su un vero thread separato e un ciclo nel main che si scambiano una variabile?</blockquote>
</div><br><div class="gmail_extra">from multiprocessing import Process, Value</div><div class="gmail_extra">import time</div><div class="gmail_extra"><br></div><div class="gmail_extra">num = Value('i', 0)</div><div class="gmail_extra">
<br></div><div class="gmail_extra">def do_something():</div><div class="gmail_extra"> while 1:</div><div class="gmail_extra"> num.value += 1</div><div class="gmail_extra"><br></div><div class="gmail_extra">p = Process(target=do_something)</div>
<div class="gmail_extra">p.start()</div><div class="gmail_extra"><br></div><div class="gmail_extra">while 1:</div><div class="gmail_extra"> print num.value</div><div class="gmail_extra"> time.sleep(1)</div><br><div>
<div><br></div></div><div>č solo un esempio preso paro paro dal tuo codice sui threads</div><div>perņ ti conviene approfondire i Manager, Queue e Pipe</div>
</div></div>