Three threads (A, B, and C) are created by extending the Thread class. Each thread prints out numbers from 1 to 4 and then prints "End of" the thread name. The main method creates instances of each thread, sets their priorities from highest (C) to lowest (A), and then starts each thread running.
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
66 views
Thread Priority
Three threads (A, B, and C) are created by extending the Thread class. Each thread prints out numbers from 1 to 4 and then prints "End of" the thread name. The main method creates instances of each thread, sets their priorities from highest (C) to lowest (A), and then starts each thread running.
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1
// Thread Priority.
class A extends Thread
{ public void run() { for (int i = 1; i <= 4; i++) { System.out.println("ThreadA : " +i); } System.out.println("End of ThreadA"); } } class B extends Thread { public void run() { for (int j = 1; j <= 4; j++) { System.out.println("ThreadB : " +j); } System.out.println("End of ThreadB"); } } class C extends Thread { public void run() { for (int k = 1; k <= 4; k++) { System.out.println("ThreadC : " +k); } System.out.println("End of ThreadC"); } } class ThreadPriority { public static void main (String args []) { A a = new A(); B b = new B(); C c = new C();