Results 1 to 2 of 2
- 10-20-2009, 05:45 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 1
- Rep Power
- 0
Generating Fibonacci Series with a Multithreaded Java Program
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...
Java Code: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); }}}
"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! :)
-
I think that it's answered adequately in your non-referenced cross-post: Java Programming - Re: Generating Fibonacci Series Using a Multithreaded Java Program
Similar Threads
-
generating trigger using java
By money3 in forum JDBCReplies: 1Last Post: 10-06-2009, 12:56 PM -
Multithreaded daemon? High level help needed.
By y0y in forum New To JavaReplies: 4Last Post: 02-05-2009, 07:06 PM -
Stopping a running thread in a multithreaded environment
By SUSHMA50 in forum Advanced JavaReplies: 11Last Post: 01-26-2009, 01:22 AM -
A simple multithreaded server
By Java Tip in forum java.netReplies: 0Last Post: 04-07-2008, 09:15 PM -
A Fibonacci printing program
By Java Tip in forum Java TipReplies: 0Last Post: 03-28-2008, 08:26 PM
Bookmarks