Results 1 to 2 of 2
  1. #1
    firesauce is offline Member
    Join Date
    Oct 2009
    Rep Power

    Default Generating Fibonacci Series with a Multithreaded Java Program 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...

    Java Code:
    import java.util.Scanner;  
    public class FibonacciThread {     
         public static void main (String[] args) { 	
         int userInput, fibonacciOutput; 	
         Scanner scan = new Scanner(;
     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! :)

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

Similar Threads

  1. generating trigger using java
    By money3 in forum JDBC
    Replies: 1
    Last Post: 10-06-2009, 11:56 AM
  2. Multithreaded daemon? High level help needed.
    By y0y in forum New To Java
    Replies: 4
    Last Post: 02-05-2009, 06:06 PM
  3. Replies: 11
    Last Post: 01-26-2009, 12:22 AM
  4. A simple multithreaded server
    By Java Tip in forum
    Replies: 0
    Last Post: 04-07-2008, 08:15 PM
  5. A Fibonacci printing program
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-28-2008, 07:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts