forked from learning-zone/java-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreadPriority.java
More file actions
26 lines (21 loc) · 890 Bytes
/
ThreadPriority.java
File metadata and controls
26 lines (21 loc) · 890 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
package multithreading;
public class ThreadPriority extends Thread {
public void run() {
System.out.println("Inside run method");
}
public static void main(String[] args) {
ThreadPriority t1 = new ThreadPriority();
ThreadPriority t2 = new ThreadPriority();
ThreadPriority t3 = new ThreadPriority();
System.out.println("Default t1 thread priority: " + t1.getPriority());
System.out.println("Default t2 thread priority: " + t2.getPriority());
System.out.println("Default t3 thread priority: " + t3.getPriority());
t1.setPriority(2);
t2.setPriority(5);
t3.setPriority(8);
System.out.println("t1 thread priority: " + t1.getPriority());
System.out.println("t2 thread priority: " + t2.getPriority());
System.out.println("t3 thread priority: " + t3.getPriority());
System.out.println("Main thread priority: " + Thread.currentThread().getPriority());
}
}