-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultithreading3.java
More file actions
28 lines (23 loc) · 835 Bytes
/
Copy pathmultithreading3.java
File metadata and controls
28 lines (23 loc) · 835 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
//Thread by constructor
class thr extends Thread {
public thr(String name) { //new type of Thread;
super(name);
}
public void run() {
while (true) {
// System.out.println("i am a thread");
}
}
}
public class multithreading3 {
public static void main(String[] args) {
thr t1 = new thr("varad");
thr t2 = new thr("viha");
t1.start();
t2.start();
System.out.println(" the id of a thread is " + t1.getId()); //.getId ham use krte hai ..ek thread ki id janane ke liye
System.out.println(" the name of a name is " + t1.getName());
System.out.println(" the id of a thread is " + t2.getId());
System.out.println(" the name of a name is " + t2.getName());
}
}