title: Design help: threading within a struct
body: <p>I'm new to Rust. As a learning exercise I'm trying to write a simple timer struct that I once wrote in C++. The interface and implementation looks something like this:</p>
  
  <pre><code>pub struct Timer {
      handle: Option&lt;std::thread::JoinHandle&lt;()&gt;&gt;,
      alive: bool,
  }
  
  impl Timer {
      pub fn new() {
          Timer {
              handle: None,
              alive: false,
          }
      }
  
      pub fn start(&amp;'static mut self) {
          // Oops! How do I do this?
          self.handle = Some(std::thread::spawn(move || {
              self.alive = true;
              self.loop()
          }));
      }
  
      pub fn stop(&amp;mut self) {
          self.alive = false;
          self.handle.unwrap().join()
      }
  
      pub fn loop(&amp;self) {
          // while alive
      }
  }
  </code></pre>
  
  <p>I understand why this is an error because of <code>use of moved value: self</code> within the <code>start</code> function, but I'm wondering how I'm supposed to <em>design</em> my struct so that something like this would work. In every scenario I can think of, I'll always have a double borrow situation.</p>
  
  <p>I have a hunch that I need to learn more about interior mutability, but figured I would ask for design guidance before going down any more rabbit holes.</p>