HP3000-L Archives

November 2000, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Reply To:
Date:
Thu, 23 Nov 2000 17:19:39 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (112 lines)
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");}
            }

        }
   }

}

ATOM RSS1 RSS2