summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/concurrent/ops.scala24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/library/scala/concurrent/ops.scala b/src/library/scala/concurrent/ops.scala
index 3bb0fb9857..25d1ad8f6b 100644
--- a/src/library/scala/concurrent/ops.scala
+++ b/src/library/scala/concurrent/ops.scala
@@ -32,12 +32,30 @@ object ops {
}
}
- /**
- * @param p ...
+ /** Creates and starts a new thread that executes
+ * a given expression.
+ *
+ * @param p the expression to execute.
+ * @return the new thread.
*/
- def spawn(p: => Unit) = {
+ def spawn(p: => Unit): Thread = {
val t = new Thread() { override def run() = p }
t.start()
+ t
+ }
+
+ /** Creates and starts a new thread that
+ * has the specified <code>name</code> as its name,
+ * and executes a given expression.
+ *
+ * @param name the name of the new thread.
+ * @param p the expression to execute.
+ * @return the new thread.
+ */
+ def spawn(name: String)(p: => Unit): Thread = {
+ val t = new Thread(name) { override def run() = p }
+ t.start()
+ t
}
/**