eu.lucaventuri.examples.ChoiceExample Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fibry Show documentation
Show all versions of fibry Show documentation
The first Java Actor System supporting fibers from Project Loom
package eu.lucaventuri.examples;
import eu.lucaventuri.common.SystemUtils;
import eu.lucaventuri.fibry.ActorUtils;
import eu.lucaventuri.fibry.Stereotypes;
public class ChoiceExample {
public static void main(String[] args) {
ActorUtils.runAsFiberScope(() -> System.out.println("Naked fiber 1!"), () -> System.out.println("Naked fiber 2!"), () -> System.out.println("Naked fiber 3!"));
ActorUtils.runAsFiber(() -> System.out.println("Naked fiber GS 1!"), () -> System.out.println("Naked fiber GS 2!"), () -> System.out.println("Naked fiber GS 3!"));
SystemUtils.sleep(10);
Stereotypes.threads().sink("Thread", null).execAsync(() -> System.out.println("From thread"));
Stereotypes.auto().sink("Auto", null).execAsync(() -> System.out.println("From auto"));
Stereotypes.fibers().sink("Fiber", null).execAsync(() -> System.out.println("From fiber"));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy