Main.java 757 Bytes
Newer Older
Michele Fiori's avatar
Michele Fiori committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
package veterinarian;

import java.util.ArrayList;
import java.util.Random;

public class Main {
    public static void main(String[] args) throws Exception {
        Random r = new Random();
        int r_int;
        String animal_s;
        WaitingRoom wr = new WaitingRoom();
        ArrayList<Thread> threads = new ArrayList<Thread>();


        for (int i=0; i<10; i++) {
            r_int = r.nextInt(2);
            if(r_int == 0) {
                animal_s = "cat";
            } else {
                animal_s = "dog";
            }
            AnimalThread at = new AnimalThread(wr, animal_s, r, i);
            threads.add(at);
        }

        for (Thread t: threads) {
            t.start();
        }
    }
}