+/EE360P
distributed systems
git clone https://git.julia.blue/+/EE360P
828c852
master
1public class Fibonacci extends Thread { 2int n ; 3int result ; 4public Fibonacci (int n ) { 5this .n =n ; 6 } 7public void run () { 8if ((n ==0 )||(n ==1 ))result =1 ; 9else { 10Fibonacci f1 =new Fibonacci (n -1 ); 11Fibonacci f2 =new Fibonacci (n -2 ); 12f1 .start (); 13f2 .start (); 14try { 15f1 .join (); 16f2 .join (); 17 }catch (InterruptedException e ){}; 18result =f1 .getResult () +f2 .getResult (); 19 } 20 } 21public int getResult (){ 22return result ; 23 } 24public static void main (String []args ) { 25Fibonacci f1 =new Fibonacci (Integer .parseInt (args [0 ])); 26f1 .start (); 27try { 28f1 .join (); 29 }catch (InterruptedException e ){}; 30System .out .println ("Answer is " +f1 .getResult ()); 31 } 32} 33