I wonder if it's possible define function that will be called in Thread's run
. It can be done by using if statement but is there a better way to do so?
a possible solution
public class WorkerThread extends Thread {
private String functionToCall = null;
public WorkerThread(String functionToCall) {
this.functionToCall = functionToCall;
}
public void run() {
if (functionToCall.equals("func1"))
func1();
else if (functionToCall.equals("func2"))
func2();
}
private void func1() {
}
private void func2() {
}
}