The only thing you can do is set a variable when you want to cancel, and test this variables in several places in the run() method:
Code:
boolean cancel;
// ....
public void run() {
cancel = false;
doSomething();
if (cancel) return;
while (somethingOrOther) {
doSomethingElse();
if (cancel) return;
}
for (int i = somenumber; i >= 0; i--) {
doSomethingAgain();
if (cancel) return;
}
doAnotherThing();
if (cancel) return;
doOneMoreThing();
return;
}
// ....
public void commandAction(Command c, Displayable d) {
if (c == cancelCommand) {
cancel = true;
}
}
If you want to cancel in the middle of one of the doSomething() methods then you'll have to check for cancel in them too. If it's a system method (part of the MIDP API), then you're screwed.
shmoove