protected void handleDistributedEvent(String name, long messageID, byte[] data) {
   NoHeapRealtimeThread.print("From ");
   NoHeapRealtimeThread.print(name);
   NoHeapRealtimeThread.print(": Time: ");
   NoHeapRealtimeThread.print(messageID);
   NoHeapRealtimeThread.print("\n");
 }
  protected void removeThread(long threadID) {
    int tid = (int) (threadID + OFFSET);

    if (enabled[tid]) {
      enabled[tid] = false;
    } else {
      NoHeapRealtimeThread.print("No such thread #");
      NoHeapRealtimeThread.print(threadID);
      NoHeapRealtimeThread.print("!\n");
      System.exit(-1);
    }
  }
  protected void addThread(long threadID) {
    int tid = (int) (threadID + OFFSET);
    numThreads = (int) (tid > numThreads ? tid : numThreads);

    if (enabled[tid]) {
      NoHeapRealtimeThread.print("Already added thread #");
      NoHeapRealtimeThread.print(threadID);
      NoHeapRealtimeThread.print("!\n");
      System.exit(-1);
    } else {
      enabled[tid] = true;
    }
  }
 public void printNoAlloc() {
   boolean first = true;
   NoHeapRealtimeThread.print("[");
   for (int i = 0; i <= numThreads; i++) {
     if (enabled[i]) {
       if (first) {
         first = false;
       } else {
         NoHeapRealtimeThread.print(" ");
       }
       NoHeapRealtimeThread.print(i - OFFSET);
     }
   }
   NoHeapRealtimeThread.print("]");
 }
  protected long chooseThread(long currentTime) {
    if (connectionManagerStarted) {
      if (serverID == 0) {
        serverID = bind(name);
      }

      if (remoteObj == null) {
        remoteObj = resolve(remoteName);
      }

      generateDistributedEvent(remoteObj, currentTime, new byte[0]);
    }

    setQuanta(10000); // Switch again after a specified number of microseconds.

    for (int newIndex = (currentThreadID + 1) % (numThreads + 1);
        newIndex != currentThreadID;
        newIndex = (newIndex + 1) % (numThreads + 1)) {
      if (enabled[newIndex]) {
        return (currentThreadID = newIndex) - OFFSET;
      }
    }
    if (!enabled[currentThreadID]) {
      NoHeapRealtimeThread.print("Deadlock!\n");
      System.exit(-1);
      return 0;
    }
    return currentThreadID - OFFSET;
  }