title: How do I declare an exception in an anonymous thread?
body: <pre><code>InputStream in = ClientSocket.getInputStream();
  new Thread()
  {
      public void run() {
          while (true)
          {
              int i = in.read();
              handleInput(i);
          }
      }
  }.start();
  </code></pre>
  
  <p>I'm listening to new data on a socket with this code and get:</p>
  
  <pre><code>FaceNetChat.java:37: unreported exception java.io.IOException; must be caught or declared to be thrown
                  int i = in.read();
                                 ^
  </code></pre>
  
  <p>When I add "<strong>throws IOException</strong>" after the "<strong>run()</strong>" I get:</p>
  
  <pre><code>FaceNetChat.java:34: run() in  cannot implement run() in java.lang.Runnable; overridden method does not throw java.io.IOException
          public void run() throws IOException {
                      ^
  </code></pre>
  
  <p>It's probably something simple, but I'm at a loss. How do I get passed this?</p>