Thread safe, means that two thing can be done with out the order mattering,
and without any dependency on the other thread.

Example:
Find the sum of a column 1-1000

Single Thread:
1+2+3+4....+998+999+1000

4 Threads:
A= 1+2+3+4...248+249+250 
B = 251+252+253+254...498+499+500 
C = 501+502+503+504...748+749+750
D = 751+752+753+754...998+999+1000

Return A+B+C+D

Not Thread Safe:

Replace all entities with Value -1 with 0
Sum column


Not Thread Safe:

New A = Old A + 3

New B = New A + Old B

Can be multithreaded for part of the operation:
Fetch  4 URLs, Store returned data, do formula, display result.

You can multithread the Fetch, and the store, but the Do formula and display
result has to happen after.






-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Greg
Sent: Tuesday, June 28, 2011 10:20 PM
To: Google App Engine
Subject: [google-appengine] Thread-safe Python Tips

Hi -

Could anyone familiar with threads explain the basic principals of python
thread-safety?

Cheers!
Greg.

--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to