diff options
author | Philipp Haller <hallerp@gmail.com> | 2008-07-24 10:25:44 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2008-07-24 10:25:44 +0000 |
commit | ca6811cfa591acaa1ff0bfa47840a032c71ebeec (patch) | |
tree | 6334281d387c0177c580c19a536ebf26b5aad90b /src | |
parent | 9117995a53c4e6f40452d470cac2175c93cef40f (diff) | |
download | scala-ca6811cfa591acaa1ff0bfa47840a032c71ebeec.tar.gz scala-ca6811cfa591acaa1ff0bfa47840a032c71ebeec.tar.bz2 scala-ca6811cfa591acaa1ff0bfa47840a032c71ebeec.zip |
Fixed #853.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/concurrent/ops.scala | 24 |
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 } /** |