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