You really don't need to do this in Java... I mean you don't need to have basic math in a separate thread unless your calculating Pi or something else only a little less lengthy.
If your just handling math, do it in line and the the compiler optimize as needed.
There are a number of ways to do it, but I suggest that you will get in the least amount of trouble if you review the Executor class in the java.util.concurrent package. The javadocs have a lot of info on how to use them (all the info you'll need to get it running).
You can find those docs here:
http://docs.oracle.com/javase/6/docs/api/index.html?java/util/concurrent/package-summary.html
Assuming you still want to do this the hard way:
However in the intrest of just giving you the darn answer already, you can do as noMADD suggested or you can also use an anonymous inner class.
class MathStuff {
boolean running = false;
int result = 0;
boolean isRunning(){
return running;
}
int getResult(){
return result;
}
int add(final int arg0, final int arg1){
Thread t = new Thread(){
public void run(){
running = true;
result = arg0 + arg1;
running = false;
}
};
t.start();
}
}
Note that I added the running member variable because the result is not valid while it returns true. Usually I'd build this kind of thing with an event listener that would receive the callback when the operation was completed, however I used a simple isRunning call so as to not obfuscate the thread part too much.