小编hud*_*ira的帖子

我怎么能使用Jython线程,因为它们是Java线程?

例如,我想是因为我要开始我的重现此主题中的Jython 的statemachine从Java API.I不要自己的很多知识在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();
Run Code Online (Sandbox Code Playgroud)

所以我正在尝试这样的事情:

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() 
Run Code Online (Sandbox Code Playgroud)

PS:我已经尝试做foo.run()下的评论

我究竟做错了什么?

java multithreading jython

6
推荐指数
1
解决办法
2045
查看次数

标签 统计

java ×1

jython ×1

multithreading ×1