Skip to content

Instantly share code, notes, and snippets.

public class ReadyReminderClientMokapotWithReminders {
public static void main(String[] args) throws Exception {
DistributedCommunicator communicator
= new DistributedCommunicator("test2.p12",
"testpassword1".toCharArray());
communicator.startCommunication();
CommunicationAddress serverAddress
= communicator.lookupAddress(InetAddress.getLoopbackAddress(), 15238);
ReadyReminderServer<String> server
= communicator.runRemotely(ReadyReminderServer<String>::new, serverAddress);
final PrintStream out = System.out;
/* The (Runnable & Serializable) annotation would be inserted by Millr */
server.submitEventWithReminder("two seconds", Instant.now().plusSeconds(2),
(Runnable & Serializable) () -> out.println("reminder for two-second event"));
server.submitEvent("one second", Instant.now().plusSeconds(1));
server.submitEventWithReminder("four seconds", Instant.now().plusSeconds(4),
(Runnable & Serializable) () -> out.println("reminder for four-second event"));
System.out.println(Objects.toString(server.extractReadyEvent()));
Thread.sleep(2500);
System.out.println(Objects.toString(server.extractReadyEvent()));
System.out.println(Objects.toString(server.extractReadyEvent()));
System.out.println(Objects.toString(server.extractReadyEvent()));
server = null;
communicator.stopCommunication();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment