| 
      
        
         Auto-Transitions 
          
          
          
          
          
          
          
          
           [Previous]   [Next]    
     | 
    ![]()  | 
      
                 User Manual [Previous]  [Next] Auto-TransitionsIt is possible to arrange for a state machine to transition automatically from one state to the next immediately after completing entry actions or upon completion of a do activity. This is specified using a transition without any preceding event. Such transitions may have guards and transition actions. Example
// In this example, the system will transition to s2 automatically
// when the do activity ends
class X {
  sm {
    s1 {
      entry / {
        System.out.println("Starting first sleep");
      }
      do {
        Thread.sleep(2000);
        System.out.println("Ending first sleep");
      }
      -> s2;
    }
    s2 {
      entry / {
        System.out.println("Starting second sleep");
      }
      do {
        Thread.sleep(2000);
        System.out.println("Ending second sleep");
      }
    }
  }
  public static void main(String [ ] args) {
    X x = new X();
  }
}
      
Load the above code into UmpleOnline SyntaxautoTransition : [[activity]]? [[autoTransitionBlock]] // Autotransitions have no event. The transition is immediately taken // or taken after the do activity ends[[guard]]? -> [[action]]? // The action can come before or after the arrow autoTransitionBlock- : [[guard]]?  ( [[action]] -> | -> [[action]] | ->  ) [stateName] ;  |