Minimum and Maximum Priority Threads : Thread Priority « Thread « Java Tutorial






public class Test {

  public static void main(String[] args) {
    Test t = new Test();
  }

  public Test() {
    Runnable runner = new MyRunnable("First");
    Thread t = new Thread(runner);
    t.setPriority(Thread.MIN_PRIORITY);
    t.start();
    runner = new MyRunnable("Second");
    t = new Thread(runner);
    t.setPriority(Thread.MAX_PRIORITY);
    t.start();
  }

  class MyRunnable implements Runnable {

    protected String name;

    public MyRunnable(String tn) {
      name = tn;
    }

    public void run() {
      while (true) {
        System.out.println(name);
      }
    }
  }

}








10.3.Thread Priority
10.3.1.Change Thread Priority
10.3.2.Demonstrate thread priorities.
10.3.3.Minimum and Maximum Priority Threads
10.3.4.This class demonstrates how to set Priority