title: How to deal with multiple threads in one class?
body: <p>Threads are often designed in two ways (<a href="http://java.sun.com/docs/books/tutorial/essential/concurrency/runthread.html" rel="noreferrer">see java tutorials</a>): either by extending the Thread class or by implementing the Runnable class. Either way, you need to specify what will run inside the thread. </p>
  
  <p>I designed a class, an adapter towards an online resource, that retrieves different kinds of information. This class consists of methods like getInformationOfTypeA() and getInformationOfTypeB(). Both contain code to connect to online resources, so both need to be threaded to avoid deadlocks. </p>
  
  <p>The question is: how should I design this? I can do it like below, but then I can only implement one method:</p>
  
  <pre><code>public class OnlineResourceAdapter implements Runnable {
  
    public void run() {
        //get stuff from resource
        getInformationOfTypeA();
    }
  
    public static void main(String args[]) {
        (new Thread(new OnlineResourceAdapter ())).start();
    }
  
    public void getInformationOfTypeA(){
        //get information of type A
    }
  
    public void getInformationOfTypeB(){
        //get information of type B
    }
  
  }
  </code></pre>
  
  <p>Another way would be by creating separate classes for each method, but that seems unnatural to me.</p>
  
  <p><em>Btw: I'm developing my application in j2me</em></p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Thanks to your responses I think it is most suiting to use something like the following as methods:</p>
  
  <p>What do you think of this:</p>
  
  <pre><code>public class OnlineResourceAdapter{
      public void getInformationOfTypeA(){
          Thread t = new Thread(new Runnable() {           
              public void run() { 
                  //do stuff here
              } 
          });
          t.start();
      }
  
      public void getInformationOfTypeB(){
          Thread t = new Thread(new Runnable() {           
              public void run() { 
                  //do stuff here
              } 
          });
          t.start();
      }
  }
  </code></pre>
  
  <p>What do you think of this?</p>