Hello,
I'm currently using a separate thread in Java that could potentially be used for a lot of different functionality, and I'm wondering if there is a way to pass the command for an actual function call as a parameter. This would look something along the lines of:
class myWorkerThread implements Runnable
{
private (<String/whatever other type>) runCommand;
public myWorkerThread(<String/whatever other type> <my command>)
{
}
public void run()
{
//Actually run that command.
}
}
I'm hoping to get a tool that doesn't make me use an ugly switch case statement or something of the sort. The different functions I'd ask the thread to run have different parameters, but I'd like to be able to run them just with the same thread.
Follow up questions/links to other resources are great.
Thanks.