forked from Malaka98/Design-Patterns-in-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
27 lines (18 loc) · 784 Bytes
/
Main.java
File metadata and controls
27 lines (18 loc) · 784 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
public class Main {
public static void main(String[] args) {
System.out.println("Enter Text >");
// create an event source - reads from stdin
final EventSource eventSource = new EventSource();
// create first observer
final ResponseHandler1 responseHandler1 = new ResponseHandler1();
// subscribe the observer to the event source
eventSource.addObserver(responseHandler1);
// create second observer
final ResponseHandler2 responseHandler2 = new ResponseHandler2();
// subscribe the observer to the event source
eventSource.addObserver(responseHandler2);
// starts the event thread
Thread thread = new Thread(eventSource);
thread.start();
}
}