I write a java program that works in NT, Linux but not MPE/IX HP 3000.
Any ideal?
The message 'do something' don't turn up.
import java.io.*;
public class test implements Runnable
{
private test aClient;
private boolean bContinue = true;
private long sleepTime= 5000;
private Thread myThread, tKeyboard;
private class Keyboard implements Runnable
{
private boolean readCharacter = true;
private void usage()
{
System.out.println
("*************************************************");
System.out.println ("'s' to stop 'r' to show status 'd'
to wake up");
System.out.println ("");
}
public void run ()
{
byte[] readBuffer = new byte[2048];
while (readCharacter && bContinue)
{
try
{
System.in.read(readBuffer);
switch (readBuffer[0])
{
case 's': case 'S':
readCharacter = false;
stop ();
break;
case 'd': case 'D':
wakeUp ();
break;
case 'r': case 'R':
showStatus();
break;
default:
usage();
break;
}
}
catch (IOException io) {}
}
}
}
public static void main (String[] args)
{
try
{
test a = new test ();
Thread aThread = new Thread (a);
a.setThread(aThread);
aThread.start ();
}
catch (Exception e)
{
System.out.println (e);
}
}
public test () throws Exception
{
tKeyboard = new Thread (new Keyboard());
tKeyboard.start();
}
public void setThread (Thread myThread)
{
this.myThread = myThread;
}
private void wakeUp ()
{
myThread.interrupt ();
}
private void stop ()
{
System.out.println ("Please wait ....");
bContinue = false;
}
private void showStatus ()
{
System.out.println ("Show status...");
}
public void run ()
{
while (bContinue)
{
System.out.println (" do something....");
if (bContinue)
{
try
{
Thread.sleep (sleepTime);
}
catch (Exception e) {System.out.println ("Wake up");}
}
}
}
}