-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavaGenUBEg8.java
41 lines (29 loc) · 940 Bytes
/
javaGenUBEg8.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
public class javaGenUBEg8<T extends Thread> {
public void run(T t) {
t.start();
System.out.println("Thread has been started...");
}
public void wait(T t) {
synchronized (t) {
try {
t.wait(1000);
} catch (InterruptedException e) {
System.out.println("Thread has been interrupted...");
}
}
}
public void notify(T t) {
synchronized (t) {
t.notify();
}
}
public static void main(String[] args) throws InterruptedException {
javaGenUBEg8<Thread> obj = new javaGenUBEg8<>();
obj.run(new Thread());
System.out.println("My name ....");
obj.wait(new Thread());
System.out.println("Avinandan Bose");
obj.notify(new Thread());
System.out.println("Thread has been notified...");
}
}