Based on my experience writing threaded applications in Jython, using Java Threads and the Runnable interface is the best practice. The following Jython script implements the best practice for building threaded applications in Jython:
from java.lang import Thread, Runnable
import synchronize
class myclass( Runnable ):
def __init__( self, myparam ):
self.storeit = myparam
def setMyparam( self, myparam ):
self.storeit = myparam
setMyparam=synchronize.make_synchronized( setMyparam )
def printMyparam( self ):
print "myclass: myparam =",self.storeit
printMyparam=synchronize.make_synchronized( printMyparam )
def run( self ):
for self.i in range(5):
self.printMyparam()
count = 2
a = myclass()
a.setMyparam( "frank" )
t = Thread( a, "MyThread %d" % count )
t.start()