Well...as the title says, I need to generate a Fibonacci series using Java's thread library (including Runnable, I assume). I really don't know where to begin. Here's all I have so far...
import java.util.Scanner;
public class FibonacciThread {
public static void main (String[] args) {
int userInput, fibonacciOutput;
Scanner scan = new Scanner(System.in);
System.out.print("Please enter a non-negative number:");
userInput = scan.nextInt();
fibonacciOutput= fib(userInput);
System.out.println("The " + userInput+ "th Fibonacci number = " + fibonacciOutput+ "."); }
public static int fib(int k) {
if (k <= 2) {
return 1;
}
else {
return fib(k-1) + fib(k-2); }}}
It's not much...I know. But I don't know where to begin. Here are more instructions on what I'm to do...
"Write a multithreaded program that generated a Fib series...User should enter number to generate to...the program will then generate a separate thread that will generate the Fib numbers, placing the sequence in data that is shared by the threads (an array is probably most convenient)..."
Any help will be greatly appreciated! :)