package Demo; object ControlFlow { implicit def all[T] (iterable : Iterable[T]) : Iterator[T] = iterable.elements; implicit def spawn[T] (funct : T => Unit) : (T => Runnable) = (arg : T) => new Runnable { def run : Unit = funct(arg);} def forEach[T] (iter : Iterator[T], action : T => Unit) : Unit = while(iter.hasNext) action(iter.next); def concurrentForEach[T] (iter : Iterator[T], action : T => Runnable) : Unit = forEach(iter, (arg : T) => new Thread(action(arg)).start()); def main(args : Array[String]) = concurrentForEach(args, (arg : String) => Console.println(arg)); }