-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultithreading4.java
More file actions
37 lines (31 loc) · 1023 Bytes
/
multithreading4.java
File metadata and controls
37 lines (31 loc) · 1023 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
//Thread priorities
//konsa thread kab run hoga . kisiko kitini priorities milegi
//
//Thread by constructor
class thr1 extends Thread {
public thr1(String name) { // new type of Thread;
super(name);
}
public void run() {
System.out.println("th is" + this.getName());
// while (true) {
// System.out.println("i am a thread");
// }
}
}
public class multithreading4 {
public static void main(String[] args) {
thr1 t1 = new thr1(" varad1");
thr1 t2 = new thr1(" varad2");
thr1 t3 = new thr1(" varad3");
thr1 t4 = new thr1(" varad4");
thr1 t5 = new thr1(" varad5 most imp"); /// is object ko hame pehle run karna hai
t5.setPriority(Thread.MAX_PRIORITY); // is ko use krke ham kisi nhi function ko priority de skte hai;;;
t1.setPriority(Thread.MIN_PRIORITY);
t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
}
}