How to suspend/interrupt from Java the execution of a Builder JA application?

Hello Everybody,
I built some MATLAB functions and I employed the MATLAB Builder JA for embedding this MATLAB functions into a Java library. My Java library presents only one public class, let's call it MyClass, which has only one method, let's say myMethod.
I would like to include myMethod in a GUI, and to give to the user the possibility of suspending/interrupting myMethod from the GUI; the execution of myMethod may require a long time, so the user may be willing of interrupting it.
However, I found no way to stop the execution of the MCR program called from myMethod. I tried to call myMethod within a Java Thread:
public Class MyThread extends Thread{
//other code
public void run(){
MyClass myObject = new MyClass();
myObject.myMethod();
}
//other code
}
However, if I try to interrupt a MyThread istance, the istance of MyThread is interrupted (as confirmed by the isInterrupted() method), but the MCR program will continue to run (and to consume resources):
//other code
MyThread myThread = new MyThread();
myThread.start();
//...
if (someConditionIsTrue){
//this will interrupt the Java Thread, NOT the underlying MCR application
myThread.interrupt();
}
//other code
I have been looking for a long time for an answer to this problem; the only similar topic I found is the following:
However, this solution does not work in my case.
Does anybody has any experience/idea about this topic?
Best Regards,
Vincenzo

Answers (0)

Asked:

on 12 Oct 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!