I have a piece of code that needs to be run on a separate thread to improve performance. An example of where all the methods to be used by the Runnable are outside the Runnable class:
public class MyClass{
public void myMethod() {
new Runnable(){
@Override
public void run() {
task1();
task2();
task3();
}
}
}
public void task1(){
}
public void task2(){
}
public void task3(){
}
}
An example of where all the methods to be used by the Runnable are inside the Runnable class:
public class MyClass{
public void myMethod() {
new Runnable(){
@Override
public void run() {
task1();
task2();
task3();
}
public void task1(){
}
public void task2(){
}
public void task3(){
}
}
}
}
I'm in a situation where any tiny bit of improvement in performance will make a significant improvement.