import org.deltacore.concurrent.AsyncExecutor; import org.deltacore.concurrent.Future; public class AsyncExample { public static void main(String[] args) { AsyncExecutor executor = new AsyncExecutor(); Future<String> futureResult = executor.submit(() -> { Thread.sleep(5000); }); String result = futureResult.get(); System.out.println(result); executor.shutdown(); } } import org.deltacore.event.Event; import org.deltacore.event.EventListener; import org.deltacore.event.EventManager; public class EventDrivenExample { public static void main(String[] args) { EventManager eventManager = new EventManager(); class CustomEvent implements Event { private final String message; public CustomEvent(String message) { this.message = message; } public String getMessage() { return message; } } eventManager.registerEventListener(CustomEvent.class, new EventListener<CustomEvent>() { @Override public void onEvent(CustomEvent event) { } }); eventManager.triggerEvent(new CustomEvent("Hello, Delta Core!")); } } import org.deltacore.config.Config; import org.deltacore.config.ConfigManager; public class ConfigurationExample { public static void main(String[] args) { ConfigManager configManager = new ConfigManager(); class MyAppConfig implements Config { private final String appName; public MyAppConfig(String appName) { this.appName = appName; } public String getAppName() { return appName; } } MyAppConfig config = configManager.loadConfig("app_config.yml", MyAppConfig.class); } }


上一篇:
下一篇:
切换中文