title: Threads and public void run()
body: <pre><code>import java.lang.Thread;
  
  class ThreadExperiment implements Runnable {
    public static void main(String[] args) {
      Thread t = new Thread(new ThreadExperiment());
      @Override
      public void run(){      
          do {
              num ++;
              try {
                  Thread.sleep(400);
              } catch (InterruptedException e){
              }
          } while (num &gt;= 0);
      }
  
      Thread t2 = new Thread(new ThreadExperiment());
      @Override
      public void run() {
          do {
              num2--;
              try {
                  Thread.sleep(400);
              } catch (InterruptedException e){
              }
          } while (num &gt;= 1);
      }
  
  
      int num = 1;
      int num2 = 10;
      t.start();
      t2.start();
      if (num == num2) {
          t.interrupt();
          t2.interrupt();
      }
    }
  }
  </code></pre>
  
  <p>Trying to tinker with threads and going round in circles, always getting so close. I want two threads, one increasing a number count, the other decreasing a number count. If they meet, I want them to stop. However I am having trouble with public void run() - at the moment, it says I don<code>t have a semi-colon next to both of them. What isn</code>t right? Is this the right place to put public void run()? </p>
  
  <p>Also, some websites are saying I need two separate classes forcreating threads - is there a reason for this? Maybe if one threads relies on calculations from the other but goes a different route, I can understand, but mine feels different, just two separate entities. </p>
  
  <p>Lastly, do I need the import statement?</p>