JAVA
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
class Main {
public static void main(String[ ] args) {
Thread name = new Thread(new Name());
// Name name = new Name();
//set priority
name.currentThread().setPriority(Thread.MIN_PRIORITY);
Thread welcome = new Thread(new Welcome());
//Welcome welcome = new Welcome();
//set priority
welcome.currentThread().setPriority(Thread.MAX_PRIORITY);
name.start();
welcome.start();
}
}
//extend the Thread class
class Welcome implements Runnable{
public void run() {
System.out.println("Welcome!");
}
}
//extend the Thread class
class Name implements Runnable{
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run