Skip to content

Instantly share code, notes, and snippets.

@924060929
Created March 24, 2017 12:37
Show Gist options
  • Save 924060929/a11cde7c4fa102e4912b6518b8832597 to your computer and use it in GitHub Desktop.
Save 924060929/a11cde7c4fa102e4912b6518b8832597 to your computer and use it in GitHub Desktop.
show a spring-statemachine demo that join can't enter when fork a substate
package org.springframework.statemachine.recipes.mytest;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.recipes.tasks.TasksHandler;
public class Main {
public static void main(String[] args) {
TasksHandler handler = TasksHandler.builder()
.task("1", taskRunnable("1"))
.task("1", "12", taskRunnable("12"))
// .task("1", "13", taskRunnable("13"))
.listener(new TasksHandler.TasksListenerAdapter() {
@Override
public void onTasksSuccess() {
System.out.println("success");
}
})
.build();
StateMachine<String, String> machine = handler.getStateMachine();
machine.start();
handler.runTasks();
}
private static Runnable taskRunnable(final String id) {
return new Runnable() {
@Override
public void run() {
System.out.println("run taskRunnable " + id);
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment