Skip to content

Instantly share code, notes, and snippets.

@Eeemil
Created April 28, 2015 13:47
Show Gist options
  • Save Eeemil/a5693d0ec8ffea3dcf2d to your computer and use it in GitHub Desktop.
Save Eeemil/a5693d0ec8ffea3dcf2d to your computer and use it in GitHub Desktop.
public class Main {
public static void main(String[] args) throws InterruptedException {
number(1);
number(2);
word("Fizz");
number(4);
word("Buzz");
word("Fizz");
number(7);
number(8);
word("Fizz");
word("Buzz");
number(11);
word("Fizz");
number(13);
number(14);
word("Fizz Buzz");
}
public static void number(final int i) throws InterruptedException {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
int x = i;
while (true) {
System.out.println(x);
x += 15;
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
});
t.start();
Thread.sleep(1000);
}
public static void word(final String s) throws InterruptedException {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
System.out.println(s);
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
});
t.start();
Thread.sleep(1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment