I have a Manager that manages a couple of FileSystems (my own abstraction). It's possible that one of these FileSystems receives no data for awhile, so I'd like to idle it. Whenever data is finally received by the Manager, it should awaken the respective idle FileSystem. Right now I'm using wait() and notify() and I get the results I want.
However, the whole point of idling a FileSystem was to consume less resources. I was wondering if it may be better to just interrupt() the Thread then create a new one when it's time to activate a FileSystem (could take ten minutes or more for new data to come in)? Wouldn't waiting still hog resources?
Here's the setup of my Runnable.
public class FileSystem implements Runnable
{
public FileSystem()
{
// do stuff
startTimer()
}
@Override
public void run()
{
while (!Thread.currentThread().isInterrupted())
{
// do stuff
}
}
//public void startTimer()
//{
// new Thread(new Runnable()
// {
// @Override
// public void run()
// {
// // do something
// }
// }).start();
//}
// other methods
}