Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- Thread powThread = new Thread(() -> pow());
- powThread.start();
- fib();
- }
- public static void pow() {
- try {
- int fir = 1;
- System.out.println("P: " + fir);
- Thread.sleep(1000);
- while(true) {
- fir *= 2;
- System.out.println("P: " + fir);
- Thread.sleep(1000);
- }
- } catch(InterruptedException e) { }
- }
- public static void fib() {
- try {
- int fir = 0;
- int sec = 1;
- System.out.println("F: " + fir);
- Thread.sleep(1000);
- System.out.println("F: " + sec);
- Thread.sleep(1000);
- while(true) {
- System.out.println("F: " + (fir + sec));
- sec += fir;
- fir = sec - fir;
- Thread.sleep(1000);
- }
- } catch(InterruptedException ex) { }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement