File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ // Program to Demonstrate Thread Priority
2+
3+ import java .util .*;
4+
5+ class A extends Thread
6+ {
7+ public void run ()
8+ {
9+ for (int i =0 ; i <=5 ; i ++)
10+ {
11+ System .out .println ("i = " + i );
12+ }
13+ System .out .println ("Exit from A" );
14+ }
15+ }
16+
17+ class B extends Thread
18+ {
19+ public void run ()
20+ {
21+ for (int j =0 ; j <=5 ; j ++)
22+ {
23+ System .out .println ("j = " + j );
24+ }
25+ System .out .println ("Exit from B" );
26+ }
27+ }
28+
29+ class C extends Thread
30+ {
31+ public void run ()
32+ {
33+ for (int k =0 ; k <=5 ; k ++)
34+ {
35+ System .out .println ("k = " + k );
36+ }
37+ System .out .println ("Exit from C" );
38+ }
39+ }
40+
41+ class ThreadPriority
42+ {
43+ public static void main (String args [])
44+ {
45+ A a = new A ();
46+ B b = new B ();
47+ C c = new C ();
48+
49+ a .setPriority (Thread .MAX_PRIORITY );
50+ b .setPriority (Thread .MIN_PRIORITY );
51+ c .setPriority (Thread .NORM_PRIORITY );
52+
53+ a .start ();
54+ b .start ();
55+ c .start ();
56+ }
57+ }
You can’t perform that action at this time.
0 commit comments