Interrupt Thread in java
I have a situation where I'm using a Thread, she call a method that will
do multiple processes, I need to use a "cancel" button in which you have
to stop the thread, I not can use: "while" ,to verify that it was canceled
because it not has loop in this process.
Ex:
Task<Void> task = new Task<Void>() {
@Override
protected Void call() throws Exception {
controller = new FirstEtapaController();
execProcess();
return null;
}
};
new Thread(task).start();
Call Method
private void execProcess() {
Thread thread = new Thread(new Runnable() {
public void run() {
getController().execMhetod();
refreshTable();
}
});
thread.start();
thread.join();
};
Ie, I need to stop this process, even when the "ExecMethod" already
running, it will take minutes, so I've gotta stop it and not have to wait
for him to finish so that , others do not continues.
No comments:
Post a Comment