Is it possible to convert a number of methods (defined in an interface and implemented in a class) to run as non-blocking threads?
Certainly, i can wrap each single method in the run() method of a thread class. But perhaps there exists a more sophisticated way to warp several different methods in one step, i.e. by a single thread class wrapper?
According to the example of 'Adamski' below, i don't want to create a new Runnable class for every method of the interface, i.e. i would like to avoid the following:
public interface MyBusinessClass
{
void a();
void b();
}
public class MyRunnable_a implements Runnable
{
private final MyBusinessClass bizClass;
public MyRunnable_a(MyBusinessClass bizClass) { this.bizClass = bizClass; }
public void run() { bizClass.a(); }
}
public class MyRunnable_b implements Runnable
{
private final MyBusinessClass bizClass;
public MyRunnable_b(MyBusinessClass bizClass) { this.bizClass = bizClass; }
public void run() { bizClass.b(); }
}