-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreadPriority.java
More file actions
29 lines (29 loc) · 1.06 KB
/
ThreadPriority.java
File metadata and controls
29 lines (29 loc) · 1.06 KB
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
import java.util.*;
class ThreadPriorityExample extends Thread
{
public void run()
{
System.out.println("Inside the run() method");
}
}
class ThreadPriority
{
public static void main(String args[])
{
ThreadPriorityExample t1=new ThreadPriorityExample();
ThreadPriorityExample t2=new ThreadPriorityExample();
ThreadPriorityExample t3=new ThreadPriorityExample();
System.out.println("Priority of thread t1 is: " +t1.getPriority());
System.out.println("Priority of thread t2 is: " +t2.getPriority());
System.out.println("Priority of thread t3 is: " +t3.getPriority());
t1.setPriority(6);
t2.setPriority(3);
t3.setPriority(9);
System.out.println("Priority of thread t1 is: " +t1.getPriority());
System.out.println("Priority of thread t2 is: " +t2.getPriority());
System.out.println("Priority of thread t3 is: " +t3.getPriority());
System.out.println("Currently executed the thread" +Thread.currentThread().getPriority());
Thread.currentThread().setPriority(10);
System.out.println("Currently executed the thread" +Thread.currentThread().getPriority());
}
}