list of dots Digital Research Alliance of Canada logo  NSERC logo  University of Ottawa logo / UniversitĂ© d'Ottawa

User Manual    [Previous]   [Next]   

Active Objects

An active object is an object that, when constructed, runs its own thread. This is indicated in Umple by the 'active' keyword followed by a block of code. A collection of active objects, working together, constitute a concurrent system.

Additional Umple features are under development to allow for sending signals to and from concurrent objects.

Example

class A {
  name;
 
  active {
    System.out.println("Object "+getName()+"is now active");
    for (int i = 1; i < 10; i++) {
      System.out.println(" "+name+" was here");
      Thread.sleep(1000);
    }
  }

  public static void main(String[] argv) {
    new A("1");
    new A("2");
  }
}

      

Load the above code into UmpleOnline

 

Syntax


activeDefinition : [=active] [[codeLangs]] [name]? [[moreCode]]+