title: Using threads and recursion in Java to calculate Fibonacci numbers
body: <p>I'm relatively new in the Java world and I have a problem which I don't understand.</p>
  
  <p>I have a Class (to get the fibonacci row):</p>
  
  <pre><code>class Fib {
      public static int f(int x){
          if ( x &lt; 2 )
              return 1;       
          else 
              return f(x-1)+ f(x-2);      
      }
  }
  </code></pre>
  
  <p>The task now is to start f(x-1) and f(x-2) each in a separate Thread.
  One time with implementing the Thread class and the other with implementing Runnable.
  As you probably know, it's an exercise from my prof.</p>
  
  <p>I know how to start a Thread in Java and I know how this whole Thread thing theoretically works, but I can't find a solution for starting separate Threads in this recursive function.</p>
  
  <p>What has to be done in the run function?</p>
  
  <p>Probably</p>
  
  <pre><code>public void run(){
  //int foo=start f(this.x-1)
      //int bar=start f(this.x-2)  
      //return foo+bar?
  }
  </code></pre>
  
  <p>And how can I paste x in my runnable function?
  Is x passed into the object at creation?</p>
  
  <pre><code>Class Fib ...{
    int x;
    public ... run ... 
    public ... f(x)....
  
  }
  </code></pre>
  
  <p>in the main method</p>
  
  <pre><code>(new Fib(x)).start();
  </code></pre>
  
  <p>Or am I on a totally wrong path?</p>