-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQue-42.java
More file actions
36 lines (36 loc) · 1.09 KB
/
Copy pathQue-42.java
File metadata and controls
36 lines (36 loc) · 1.09 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
30
31
32
33
34
35
36
//Generate 3 threads each generating numbers from 1 to 5 and set the priority of 4 threads to maximum , normal and minimum and display the output.
//By: Parth Panjwani
class Que42 {
public static void main(String[] args) {
Thread t1 = new Thread(new Runnable() {
public void run() {
for(int i=1;i<=5;i++)
{
System.out.println(i);
}
}
});
Thread t2 = new Thread(new Runnable() {
public void run() {
for(int i=1;i<=5;i++)
{
System.out.println(i);
}
}
});
Thread t3 = new Thread(new Runnable() {
public void run() {
for(int i=1;i<=5;i++)
{
System.out.println(i);
}
}
});
t1.setPriority(Thread.MAX_PRIORITY);
t2.setPriority(Thread.NORM_PRIORITY);
t3.setPriority(Thread.MIN_PRIORITY);
t1.start();
t2.start();
t3.start();
}
}