use System.Concurrency;
use Collection;

bundle Default {
  class Item from Thread {
    @value : Int;

    New(value : Int) {
      Parent();
      @value := value;
    }

    method : public : Run(param : System.Base) ~ Nil {
      Sleep(1000 * @value);
      @value->PrintLine();
    }
  }

  class SleepSort {
    function : Main(args : String[]) ~ Nil {
      items := Vector->New();
      each(i : args) {
        items->AddBack(Item->New(args[i]->ToInt()));
      };

      each(i : items) {
        items->Get(i)->As(Item)->Execute(Nil);
      };
    }
  }
}
