6
例如我想在Jython中重现此线程,因为我需要从Java API开始我的状态机。我没有在Jython中拥有太多知识。我怎样才能做到这一点?我如何使用Jython线程,因为它们是Java线程?
Thread thread = new Thread() {
@Override
public void run() {
statemachine.enter();
while (!isInterrupted()) {
statemachine.getInterfaceNew64().getVarMessage();
statemachine.runCycle();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
interrupt();
}
}
}
};
thread.start();
所以我想是这样的:
class Cycle(Thread, widgets.Listener):
def run(self):
self.statemachine = New64CycleBasedStatemachine()
self.statemachine.enter()
while not self.currentThread().isInterrupted():
self.statemachine.getInterfaceNew64().getVarMessage()
self.statemachine.runCycle()
try:
self.currentThread().sleep(100)
except InterruptedException:
self.interrupt()
self.start()
foo = Cycle()
foo.run()
#foo.start()
PS:我已经尝试过做什么foo.run()
我在做什么错在评论?
非常感谢您,我认为我的问题与线程无关,只与我的状态机有关。非常感谢您的关注! – hudsonsferreira 2012-07-15 23:10:41