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

Thread method countStackFrame() always returns the number of stack frame.

    XMLWordPrintable

Details

    • x86, sparc
    • solaris_2.3, windows_nt

    Description

      :
      public int countStackFrame() always returns the number of stack frames
      regardless of the thread status (suspended or unsuspended).


      ---code----
      class runitforever implements Runnable {
        public void run() {
          while ( true ) {
            System.out.println("run it?");
            if (Math.random() < 0.77)
      // yield to others sometimes
      Thread.yield();
          try {
            Thread.currentThread().countStackFrames();
          } catch ( IllegalStateException test_e) {
            //exception_count++;
            System.out.println("IllegalStaeException thrown by countStackFrame() is caught");
          }

          }
        }
      }

      class threadtest03 {
        public static void main( String args[] ) {

         runitforever rt = new runitforever();

          Thread pt = new Thread(rt);



          pt.start();

          Thread.sleep(100);



          //countStackFrames() when it is not suspended
          try {
            if ( pt.countStackFrames() > 0 ) System.out.println("ok");
          } catch ( IllegalStateException test_e) {
            exception_count++;
            System.out.println("IllegalStaeException thrown by countStackFrame() is aught");
          }
      }

      Attachments

        Issue Links

          Activity

            People

              jjb Josh Bloch
              duke J. Duke
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: