[Tutor] Threading in Python
dman
dsh8290@rit.edu
Sun, 24 Mar 2002 14:42:47 -0600
On Fri, Mar 22, 2002 at 01:10:32PM +0530, Karthik Gurumurthy wrote:
| what is the basic difference in threading model of say java and python?
| i ask this because i find all the method names in the library to be very
| similar.
synchronized ( <name> )
{
<code block>
}
The key differences are :
o Python doesn't have a 'synchronized' keyword
o each object in python does not have an implicit "lock" object
associated with it
Thus the locking is all done "manually" via a method call. The above
Java looks like this in python :
<name> = threading.Lock()
<name>.acquire()
<code block>
<name>.release()
Of course, "<name>" is a placeholder for an identifier and
"<code block>" is a placeholder for a block (or snippet) of code.
-D
--
A)bort, R)etry, B)ang it with a large hammer