Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1.  
  2. public class Main {
  3.     public static void main(String[] args) {
  4.         Thread powThread = new Thread(() -> pow());
  5.         powThread.start();
  6.         fib();
  7.     }
  8.  
  9.     public static void pow() {
  10.         try {
  11.             int fir = 1;
  12.             System.out.println("P: " + fir);
  13.  
  14.             Thread.sleep(1000);
  15.  
  16.             while(true) {
  17.                 fir *= 2;
  18.                 System.out.println("P: " + fir);
  19.  
  20.                 Thread.sleep(1000);
  21.             }
  22.         } catch(InterruptedException e) { }
  23.     }
  24.  
  25.     public static void fib() {
  26.         try {
  27.             int fir = 0;
  28.             int sec = 1;
  29.  
  30.             System.out.println("F: " + fir);
  31.  
  32.             Thread.sleep(1000);
  33.  
  34.             System.out.println("F: " + sec);
  35.  
  36.             Thread.sleep(1000);
  37.  
  38.             while(true) {
  39.                 System.out.println("F: " + (fir + sec));
  40.                 sec += fir;
  41.                 fir = sec - fir;
  42.  
  43.                 Thread.sleep(1000);
  44.             }
  45.         } catch(InterruptedException ex) { }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement