   import javax.realtime.*;

   public class Thruster 
   {   
      public static void main(String [] args)
      {
         RealtimeThread rt = new TestThread();
         System.out.println("starting rt" );
      
         rt.start();
      }
   }


   class TestThread extends RealtimeThread
   {
      public void run()
      {
         System.out.println("test thread starting " );
      
         ImmortalMemory im = ImmortalMemory.instance();
         im.enter(
            //ScopedMemory sm = new VTMemory(1000000,1000000);
            //sm.enter(
               new Runnable()
               {
                  public void run()
                  {
                  
                     PriorityScheduler ps = (PriorityScheduler)Scheduler.getDefaultScheduler();
                  
                  
                     PriorityParameters pp1 = new PriorityParameters(ps.getNormPriority());
                  
                  
                     RealtimeThread rtt1 = 
                        new RealtimeThread(pp1) {
                           public void run()
                           {
                              System.out.println("Thread 1 starting " );
                              AsyncEvent thrusterButton  = new AsyncEvent();
                              //thrusterButton.bindTo("ThrusterButton");
                              
                              //PeriodicTimer control = new PeriodicTimer(
                              //new RelativeTime(1000,0), 
                             // new RelativeTime(1000,0),
                              //new AsyncEventHandler(new EngineControl())
                              //);
                              ThrusterButtonHandler tbh = new ThrusterButtonHandler(
                                     thrusterButton, new ThrusterDial(), 
                                     new EngineControl());
                              System.out.println("Events and handlers created " );
                              PriorityScheduler ps = (PriorityScheduler)Scheduler.getDefaultScheduler();
                           
                              try {
                                 Thread.sleep(500);
                                 System.out.println("firing thruster button " );
                                 thrusterButton.fire();
                                 Thread.sleep(50000);
                              }
                                 catch(InterruptedException I) {System.out.println("exception " );
                                 }; 
                           
                           }
                        };
                  
                  
                  
                     rtt1.start();
                  }
               }
            );
         System.out.println("Main ended " );      
      
      
      };
   }
