-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread_priorities.java
More file actions
37 lines (32 loc) · 957 Bytes
/
thread_priorities.java
File metadata and controls
37 lines (32 loc) · 957 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
31
32
33
34
35
36
37
class MyThr1 extends Thread{
public MyThr1(String name){
super(name);
}
public void run(){
int i = 34;
while(true){
System.out.println("Thank you: " + this.getName());
}
}
}
public class thread_priorities {
public static void main(String[] args) {
// Ready Queue: T1 T2 T3 T4 T5
MyThr1 t1 = new MyThr1("jay");
MyThr1 t2 = new MyThr1("viru");
MyThr1 t3 = new MyThr1("om");
MyThr1 t4 = new MyThr1("marry");
MyThr1 t5 = new MyThr1("priti(most Important)");
t5.setPriority(Thread.MAX_PRIORITY);
t1.setPriority(Thread.MIN_PRIORITY);
t2.setPriority(Thread.MIN_PRIORITY);
t3.setPriority(Thread.MIN_PRIORITY);
t4.setPriority(Thread.MIN_PRIORITY);
t5.setPriority(Thread.MIN_PRIORITY);
t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
}
}