package org.syndicate_lang.actors.example.example1; import org.syndicate_lang.actors.Actor; import org.syndicate_lang.actors.Ref; public class Main { public static void main(String[] args) throws InterruptedException { Actor.convenientLogging(); final var vh = Actor.forEntity(new ValueHolder<>("There")); vh.getActor().daemonize(); final var m = Actor.forEntity(new Main()); m.async(10, (m_, ac) -> m_.run(ac, vh)); @SuppressWarnings("unchecked") IValueHolder vv = vh.syncProxy(IValueHolder.class); System.out.println("Value: " + vv.get()); vv.set("Second"); System.out.println("Value: " + vv.get()); System.out.println("Underlying: " + Ref.from(vv)); Actor.awaitAll(); System.out.println("Overall main returning"); } private Actor me; private int greetingCounter = 0; public void run(Actor me, Ref> vh) { this.me = me; this.greet((String) vh.syncProxy(IValueHolder.class).get()); vh.syncVoid((v, _ac) -> v.set("World")); me.every(1000, () -> { if (greetingCounter >= 3) me.stop(); this.greet(vh.sync((v, _ac) -> v.get()).await()); }); } public void greet(String who) { me.log().info((greetingCounter++) + ": Hi " + who); } }