From: Ype K. <yk...@xs...> - 2002-03-19 17:53:40
|
Stephen, >I'm porting some Java code to Jython. How woould I write a synchronised >block? > >synchronized(some_object){ > //code >} Have a look at http://mail.python.org/pipermail/jpython-interest/2000-August/003718.html It contains an example on how to synchronize a method on the object it is invoked on. You can also use a Lock from the thread module and explicity acquire and release it. This could be a bit slower, but it's more straightforward when your code is not a complete method. If you need the performance of the java synchronized construct, you can also leave the code in java. >Thanks My pleasure, Ype -- |