src/Pure/library.scala
changeset 38556 dd7dcb9b2637
parent 38488 00b72526dc64
child 38877 ff7f9510b0d6
     1.1 --- a/src/Pure/library.scala	Tue Aug 10 12:08:24 2010 +0200
     1.2 +++ b/src/Pure/library.scala	Tue Aug 10 12:09:53 2010 +0200
     1.3 @@ -6,11 +6,12 @@
     1.4  
     1.5  package isabelle
     1.6  
     1.7 -import java.lang.System
     1.8 +
     1.9 +import java.lang.{System, Thread}
    1.10  import java.awt.Component
    1.11  import javax.swing.JOptionPane
    1.12  
    1.13 -
    1.14 +import scala.actors.Actor
    1.15  import scala.swing.ComboBox
    1.16  import scala.swing.event.SelectionChanged
    1.17  
    1.18 @@ -138,4 +139,15 @@
    1.19          ((stop - start).toDouble / 1000000) + "ms elapsed time")
    1.20      Exn.release(result)
    1.21    }
    1.22 +
    1.23 +
    1.24 +  /* thread as actor */
    1.25 +
    1.26 +  def thread_actor(name: String)(body: => Unit): Actor =
    1.27 +  {
    1.28 +    val actor = Future.promise[Actor]
    1.29 +    val thread = new Thread(name) { override def run() = { actor.fulfill(Actor.self); body } }
    1.30 +    thread.start
    1.31 +    actor.join
    1.32 +  }
    1.33  }