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

hangs over Arrays.parallelSort indefinitely

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Linux Java HotSpot(TM) 64-Bit Server VM (11.0.5+10-LTS mixed mode)

      A DESCRIPTION OF THE PROBLEM :
       i use Arrays.parallelSort to do sort, but i never get the result, it's hangs indefinitely. when i print the jstack, i found that all the worker of ForkJoinPool.commonPool is in idle

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      use Arrays.parallelSort to sort arr[]

      ACTUAL -
      it's hangs indefinitely

      ---------- BEGIN SOURCE ----------

         public static void main(String[] args) {
            Thread[] threads = new Thread[4];

            for(int i = 0; i < 4; i++) {
               threads[i] = new Thread(() -> {
                  String[] arr = new String[100000];

                  for(int i1 = 0; i1 < 100000; i1++) {
                     arr[i1] = UUID.randomUUID().toString();
                  }

                  Arrays.parallelSort(arr);
                  System.out.println("End sort." + arr[0]);
               });
               threads[i].start();
            }

            for(Thread thread : threads) {
               try {
                  thread.join();
               }
               catch(InterruptedException e) {
                  e.printStackTrace();
               }
            }

            System.out.println("End all sort.");
         }

      ---------- END SOURCE ----------

      FREQUENCY : rarely


            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: