Java Objects vs Pythons?

Gordon McMillan gmcm at hypernet.com
Fri Jun 23 22:43:42 EDT 2000


Arinté wrote: 

>I want to do a wait object like in java.  

[snip]

>waitObject = ???<What type of Lock should I use
>def callbackNotify():
>    waitObject.acquire()
>    waitObject.notifyAll()
>    waitObject.release()
>
>...
>#main do some stuff
>waitObject.acquire()
>waitObject.wait()
>waitObject.release()

That's a threading.Condition.

>In the script I don't create any threads or anything, can I do a wait
>object without creating a thread (pretty sure you can't do that in
>java)?  I guess there kinda is a thread because there is the python
>script and then there is the C++ app with the callback(usually waiting
>for output to finish on a printer).  What kind of Lock would be best the
>Lock or RLock or other? 

Without threads, none of these will do you any good. I guess you want 
somebody to block while "waiting", but who (C++ or Python) or what 
"waiting" means in this context, I don't know...



More information about the Python-list mailing list