Threads are often designed in two ways (see java tutorials): either by extending the Thread class or by implementing the Runnable class. Either way, you need to specify what wil
Many people have already suggested good methods of how to do this using several classes. Since you seem to prefer a way which doesn't require multiple classes, you might also want to consider using the constructor to give information about which resource to fetch:
public class OnlineResourceAdapter implements Runnable
{
private string resourceType;
public OnlineResourceAdapter(string resourceType)
{
this.resourceType = resourceType;
}
public void run() {
if (resourceType.equals("A") {
getInformationOfTypeA();
} else {
// etc..
}
}
public void getInformationOfTypeA(){
//get information of type A
}
public void getInformationOfTypeB(){
//get information of type B
}
}
Usage:
(new Thread(new OnlineResourceAdapter("A"))).start();