title: Background task in Scala
body: <p>I have a cache I want to periodically check and prune. In Java, I'd do the following:</p>
  
  <pre><code>new Thread(new Runnable() {
    void run() {
      while (true) { 
        Thread.sleep(1000);
        // clear the cache's old entries
      }
    }
  }).start();
  </code></pre>
  
  <p>Sure, I'd have some issues with thread-safe types to use as the cache, but putting that aside, my question is simple. What's the Scala way of running a recurring background task -- something you don't want running in the application's main thread?</p>
  
  <p>I've used actors a bit and I guess my problem in this scenario is that I don't have anything to generate a message that it's time to clear the cache. Or rather, the only way I can imagine to generate those messages is to create a thread to do it...</p>
  
  <p><strong>EDIT: I need people to vote on answers -- they all look good to me</strong></p>