在runnable类中循环时终止java fx应用程序

9rnv2umw  于 2021-07-08  发布在  Java
关注(0)|答案(0)|浏览(191)

我上过这门课

public class EXEC implements Runnable{
 private final AtomicBoolean running = new AtomicBoolean(false);

 WebDriver driver;
public EXEC(WebDriver driver) {
    this.driver = driver;
}     
public void stop() {
    running.set(false);
}

@Override
public void run() {
    // TODO Auto-generated method stub
    String pass=SampleController.getMyVariable();
     running.set(true);
     while(running.get()){
    int i=1;
    i++;
    System.out.println(i);
 }
     Platform.exit();
}
}

在ui控制器类中,我用如下方法分配了run和quit按钮

EXEC mythread=  new EXEC(drivers);

public void run()
{mythread.run();}

public void quit()
{ mythread.stop();}
``` `mythread.run()` 为我工作。但是它没有被终止 `mythread.stop();` . 请帮我怎么弄到它

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题