<br><br><div class="gmail_quote">On Sat, Aug 15, 2009 at 7:23 PM, Dennis Lee Bieber <span dir="ltr"><<a href="mailto:wlfraed@ix.netcom.com">wlfraed@ix.netcom.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Sat, 15 Aug 2009 14:34:36 -0600, John Haggerty <<a href="mailto:bouncyinc@gmail.com">bouncyinc@gmail.com</a>><br>
declaimed the following in gmane.comp.python.general:<br>
<div class="im"><br>
> What does the term "thread safe" mean exactly. I never had to program with<br>
> "threads" before<br>
<br>
</div>        That, part way through the logic of the function, control could be<br>
switched to a different thread which call the same function... This<br>
second call would change some of the internal values and may then be<br>
preempted and control returned to the first thread, which continues the<br>
rest of the function with different values then it had when first<br>
preempted.<br>
<br>
        A very contrived example, untested of course, consider it<br>
pseudo-code...<br>
<br>
startt = None<br>
<br>
def atimer():<br>
        global startt<br>
        startt = time.time()<br>
        time.sleep(5)<br>
        print time.time() - startt<br>
<br>
t1 = threading.thread(atimer)<br>
t2 = threading.thread(atimer)<br>
t1.start()<br>
t2.start()<br>
<br>
Say t1 gets all the way up to the sleep call, and (since sleep is a<br>
releasing call), t2 then starts. t2 changes the value of startt; and<br>
sleeps... both sleep and presuming the resolution is fine enough, t1<br>
resumes, and  prints a delta time that is incorrect -- it is printing<br>
the time difference from when t2 started to sleep, not from when t1<br>
started to sleep.<br>
--<br>
        Wulfraed         Dennis Lee Bieber               KD6MOG<br>
        <a href="mailto:wlfraed@ix.netcom.com">wlfraed@ix.netcom.com</a>   <a href="HTTP://wlfraed.home.netcom.com/" target="_blank">HTTP://wlfraed.home.netcom.com/</a><br>
<font color="#888888"><br>
--<br>
</font><div><div></div><div class="h5"><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br>Interesting so it seems that the compiler(c/c++)interpreter(perl, python)/vm(java) doesn't do this?<br>