8.2. Hello World Using notify
For a simple example we are going to return to the “Hello World” application from Chapter 1. You will recall that we wrote a message entry into a space and then read it and printed its content, which happens to be the String “Hello World”. Now we are going to adapt that program to use the notify method instead of read.
To do so, our application will first register a listener that is interested in Message entries arriving in the space. Then, as in the original version, we will write a Message entry into the space. When the new entry arrives in the space, the space notifies the listener by calling the listener's notify method. The listener responds to the event by reading the Message entry from the space and printing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access