Например, я хочу воспроизвести этот поток в Jython, потому что мне нужно запустить машину состояний из Java API. У меня мало знаний в Jython. Как я могу это сделать?
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()
Что я делаю не так?