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

Blocked thread status is incorrectly reported as runnable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • hotspot
    • None
    • b45
    • generic
    • windows_2000

        /* This test is used to test jdb reporting wrong thread status information
           Steps to reproduce the problem:
             jdb FooTest
             stop at FooTest:53 - the last line in changeVarOne()
             run
             cont - a few times
             threads

           All but one of Thread-0 through Thread-9 should be "waiting on a
           monitor". But jdb reports more more than one threads "running". If you do a
           where <thread id> on the running threads, you will see they are actually
           waiting to enter the synchornized method. It seemed like once a thread has
           been marked as running, jdb will always think it's a running thread even.
        */
        public class FooTest
        {
            private static int _var;

            public static void main(String[] args) throws Exception
            {
                for( int i = 0; i < 10; i++ )
                {
                    final int j = i;
                    try
                    {
                        new Thread(
                            new Runnable()
                            {
                                public void run()
                                {
                                    method( j );
                                    method( j );
                                    method( j );
                                }

                                public void method( int i )
                                {
                                    changeVarOne(i);
                                }

                            }
                        ).start();
                    }
                    catch( Exception e ) {}
                }
            }

            public static int _varOne = -1;

            synchronized static public void changeVarOne(int value)
            {
                boolean b = false;
                _varOne = value;
            }
        }

              mchung Mandy Chung (Inactive)
              alanb Alan Bateman
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: