Write a JAVA program which will generate the following threads:- I > To display 10 terms of Fibonacci searies. II > To display 1-20 in reverse order.(Using Multithreading)
import java.io.*; class Fib extends Thread { int n,i,f,s,l; Fib() { System.out.println(this); start(); } public void run() { try { l=0; f=0;s=1; System.out.println(f+""+s); i=3; while(i<=10) { l=f+s; System.out.println(l); f=s;s=l; i++; }} catch(Exception e) {} }} class Rev extends Thread { int i; Rev() { System.out.println(this); start(); } public void run() { for(i=20;i>=1;i--) { System.out.println(i+""); }}} class slip16 { public static void main(String args[]) { Fib f=new Fib(); Rev r=new Rev(); }}
Write a JAVA program which will generate the following threads:- I > To display 10 terms of Fibonacci searies. II > To display 1-20 in reverse order.(Using Multithreading)
Reviewed by
on
April 27, 2015
Rating: