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