-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy path_8.PriorityThread.java
More file actions
30 lines (27 loc) · 874 Bytes
/
_8.PriorityThread.java
File metadata and controls
30 lines (27 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class MyThread extends Thread
{
public void run()
{
System.out.println("***Priority of threads being checked***");
}
}
public class Main
{
public static void main(String[] args)
{
MyThread t1 = new MyThread();
t1.run();
System.out.println("t1 Priority :"+t1.getPriority()); //displaying predefined priorities
MyThread t2 = new MyThread();
System.out.println("t2 Priority :"+t2.getPriority());
MyThread t3 = new MyThread();
System.out.println("t3 Priority :"+t3.getPriority());
System.out.println();
t1.setPriority(3); //assigning priorities by changing predefined priorities
t2.setPriority(5);
t3.setPriority(7);
System.out.println("t1 Priority :"+t1.getPriority());
System.out.println("t2 Priority :"+t2.getPriority());
System.out.println("t3 Priority :"+t3.getPriority());
}
}