Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4492918

TTY: debugee output not seen until a newline is written

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.4.0
    • core-svc
    • None
    • beta3
    • generic
    • solaris_2.6
    • Not verified

      Message from Apple below shows on a test example that JDB stops printing
      output of multi-threaded application. Needs to be fixed. PLease see
      below.

      Message from Apple:
      ===================

      I have a test program that contains a main thread, and another thread named "SpawnedThread". Each thread waits five seconds then prints some diagnostic output. The main thread prints dots, "SpawnedThread" prints integers starting at 0.

      Here is the test case:

      NewThread.java:
      public class NewThread
      {
          public static void main(String[] args) {

              System.out.println("Spawning a new thread in 10 seconds");

              long startTime = System.currentTimeMillis();

              while(System.currentTimeMillis() < startTime + 10000)
              {
                      //wait
              }

              Thread t = new SpawnedThread("Spawned Thread");
              t.start();

              System.out.println("Thread spawned.");

              long lasttime = 0;
              while(true)
              {
                  if(System.currentTimeMillis() > lasttime + 5000) {
                      lasttime = System.currentTimeMillis();
                      System.out.print(".");
                  }
              }
          }
      }

      SpawnedThread.java:
      public class SpawnedThread extends Thread
      {
              public SpawnedThread(String name)
              {
                      super(name);
              }

              public void run()
              {
                  int a = 0;
                  long lasttime = 0;

                  while(true)
                  {
                      if(System.currentTimeMillis() > lasttime + 5000) {
                          System.out.print(a++);
                          lasttime = System.currentTimeMillis();
                      }
                  }
             }
      }

      When the program runs with the normal java command, it prints "Spawning a new thread in 10 seconds". After 10 seconds elapse, it prints "0Thread spawned." The '0' is the first output from the spawned thread. After five more seconds, the seperate threads start send their output in five second intervals. The main thread prints '.', and SpawnedThread prints integers. So, the rest of the output looks like '.1.2.3.4.5' (ad infinitum) When the program runs under jdb, it prints "VM Started: Spawning a new thread in 10 seconds". After 10 seconds elaps, it prints "0Thread spawned." Subsequent output from the program never shows up. Using different jdb commands, it's apparent that the threads are still running, but the output is nowhere to be seen.

            tbell Tim Bell
            ksoshals Kirill Soshalskiy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: