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

setPriority in Multithreading

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 15.0.1
    • hotspot
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      i will send a sample of priority based program.you can check it which is not give output according to given priority in code....


      class A extends Thread
      {
      int i;
      public void run()
      {
      for(i=1;i<=5;i++)
      System.out.println("i="+i);
      System.out.println("Exit from Class A");
      }
      }
      class B extends Thread
      {
      int j;
      public void run()
      {
      for(j=1;j<=5;j++)
      System.out.println("j="+j);
      System.out.println("Exit from Class B");
      }
      }
      class C extends Thread
      {
      int k;
      public void run()
      {
      for(k=1;k<=5;k++)
      System.out.println("k="+k);
      System.out.println("Exit from Class C");
      }
      }

      class mthread
      {
      public static void main(String args[])
      {
      A x=new A();
      B y=new B();
      C z=new C();

      z.setPriority(Thread.MAX_PRIORITY); //not work bcz it depend on jvm not on u
      y.setPriority(x.getPriority()+1);
      x.setPriority(Thread.MIN_PRIORITY);

      System.out.println("Started Thread A");
      x.start();
      System.out.println("Started Thread B");
      y.start();
      System.out.println("Started Thread C");
      z.start();
      }
      }




      A DESCRIPTION OF THE PROBLEM :
      setPriority() method in java is not work according to user.beacuse JVM and then OS determine the priority of the thread in a program that's why user cannot able to get output according to them.then why java provide setPriority() method if this method not works properly. So I hope JAVA team action on it and resolve as soon as possiible.Thnakyou


            sswsharm swati sharma (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: