-
Notifications
You must be signed in to change notification settings - Fork 0
/
practice1.java
41 lines (38 loc) · 967 Bytes
/
practice1.java
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
38
39
40
41
class Thread1 extends Thread{
public void run(){
while(true){
try{
Thread.sleep(200);
}
catch (Exception e){
System.out.println(e);
}
System.out.println("Good Morning");
}
}
}
class Thread2 extends Thread{
public void run(){
while(true){
try{
Thread.sleep(200);
}
catch (Exception e){
System.out.println(e);
}
System.out.println("Welcome");
}
}
}
public class practice1 {
public static void main(String[] args) {
Thread1 t1 = new Thread1();
Thread2 t2 = new Thread2();
t1.start();
t2.start();
t1.setPriority(10);
t2.setPriority(5);
System.out.println("priority of thread 1 is" + t1.getPriority());
System.out.println("priority of thread 2 is" + t2.getPriority());
}
}