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

Solaris only: destroying more than 5 threads at the same time causes segv

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.0fcs
    • CPU:
      sparc
    • OS:
      solaris_2.3
    • Verification:
      Verified

      Description

      Solaris, multiprocessor only: Destroying more than 5 threads at the same time causes a
      segv

      Steps to reproduce;
      Compile and run the following code on an MP computer.

      /* This test creates 1 to 100 threads. Each thread goes into a loop
         calling a synchronized function. After 5 seconds, the
         threads are all killed and the total number of successful method
         calls are tallied and displayed. */

      class monitortestT extends Thread {
          int count = 0;
          boolean die = false;

          synchronized char getChar() {
              count++;
              return 'a';
          }
          public void run() {
              setPriority(Thread.MIN_PRIORITY);
              while (!die) {
                  getChar();
              }
          }
      }

      public class monitortest
      {
          public static final int MAX_THREADS = 100;

          public static void main(String args[])
          {
             monitortestT threads[] = new monitortestT[MAX_THREADS];

             for (int i = 1; i <= MAX_THREADS; i++)
             {
                System.out.print(i + " threads: ");

                long count = 0;
                long end;

                for (int j=0; j<i; j++)
                {
                   threads[j] = new monitortestT();
                }

                long start = System.currentTimeMillis();
                for (int j=0; j<i; j++)
                {
                   threads[j].start();
                }
                try
                {
                   Thread.currentThread().sleep(5000);
                }
                catch (InterruptedException e) {}

                for (int j=0; j<i; j++)
                {
                   threads[j].die = true;
                   count += threads[j].count;
                }

                end = System.currentTimeMillis();
                System.out.print(" "+count+"/"+(end-start)+"ms = ");
                double result = (float)count/(float)(end-start)*1000.0;
                System.out.println(result+"/sec");
                for (int j=0; j<i; j++)
                {
                   try
                   {
                      threads[j].join();
                   }
                   catch (InterruptedException e) {}
                   System.out.print(threads[j].count + " ");
                }
                System.out.println();
                System.out.println();
                if (i>=5) i += 4;

             } // endfor i < 51

             System.exit(0);

          } // end main()
      } // end class monitortest


        Attachments

          Activity

            People

            Assignee:
            tlindholsunw Timothy Lindholm (Inactive)
            Reporter:
            kasmithsunw Kevin Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: