I have developed a small Java application that runs two scheduled threads via a scheduled executor service. On most computers my application runs just fine. In testing however I have come across a computer where my threads are not running as often as they should or not at all. I have one thread scheduled to run on 250 ms intervals. It simply checks to see if there is anything to read on std in, if there is it reads it and executes a command. This thread runs sporadically but never as often as it should. My other thread runs every 5 seconds and simply prints something to the screen. It runs once and then never gets ran again. Here is the code I am using:
scheduledThreadManager.scheduleWithFixedDelay(new Runnable()
{
@Override
public void run()
{
try
{
if(inputReader.ready())
{
String command = inputReader.readLine();
executeCommand(command);
}
}
catch(IOException e)
{
System.out.println(e.toString());
e.printStackTrace();
}
}
}, 250, 250, TimeUnit.MILLISECONDS);
scheduledThreadManager.scheduleWithFixedDelay(new Runnable()
{
@Override
public void run()
{
System.out.println(idleString);
}
}, 0, 5000, TimeUnit.MILLISECONDS);
I have made sure that my app is not hanging during execution of the scheduled threads. The computer has a Core2Duo processor in it so I can't see how the hardware would not be able to meet my needs, but perhaps that is not so. The other interesting thing is that I am running a main application thread in addition to these and it is running correctly. Any input into what the cause of this problem is would be greatly appreciated.