optional daemon flag;
authorwenzelm
Mon Aug 23 16:50:09 2010 +0200 (2010-08-23)
changeset 3863894ed0f34aea2
parent 38637 03b27bd0505e
child 38639 f642faca303e
optional daemon flag;
src/Pure/Concurrent/simple_thread.scala
     1.1 --- a/src/Pure/Concurrent/simple_thread.scala	Mon Aug 23 16:13:13 2010 +0200
     1.2 +++ b/src/Pure/Concurrent/simple_thread.scala	Mon Aug 23 16:50:09 2010 +0200
     1.3 @@ -16,9 +16,10 @@
     1.4  {
     1.5    /* plain thread */
     1.6  
     1.7 -  def fork(name: String)(body: => Unit): Thread =
     1.8 +  def fork(name: String, daemon: Boolean = false)(body: => Unit): Thread =
     1.9    {
    1.10      val thread = new Thread(name) { override def run = body }
    1.11 +    thread.setDaemon(daemon)
    1.12      thread.start
    1.13      thread
    1.14    }
    1.15 @@ -26,10 +27,10 @@
    1.16  
    1.17    /* thread as actor */
    1.18  
    1.19 -  def actor(name: String)(body: => Unit): Actor =
    1.20 +  def actor(name: String, daemon: Boolean = false)(body: => Unit): Actor =
    1.21    {
    1.22      val actor = Future.promise[Actor]
    1.23 -    val thread = fork(name) { actor.fulfill(Actor.self); body }
    1.24 +    val thread = fork(name, daemon) { actor.fulfill(Actor.self); body }
    1.25      actor.join
    1.26    }
    1.27  }