package tunbridge;

import java.lang.InterruptedException;
import java.lang.Thread;

public class Main {
    public static void main(String[] args) {
        Bridge bridge = new Bridge();

        cross(new SouthBoundFarmer(bridge));
        cross(new NorthBoundFarmer(bridge));
    }

    private static void cross(Farmer f) {
        new Thread(f).start();
    }
}

package tunbridge;

import java.lang.InterruptedException;
import java.lang.Thread;
import java.util.Random;

public class Main {
    final private static int FARMERS = 10;

    public static void main(String[] args) {
        Bridge bridge = new Bridge();
        Random r = new Random();

        System.out.println("Running with " + FARMERS + " farmers...");
        for (int i = 0; i < FARMERS; i++) {
            Farmer farmer;
            if (r.nextBoolean()) {
                farmer = new SouthBoundFarmer(bridge);
            } else {
                farmer = new NorthBoundFarmer(bridge);
            }
            cross(farmer);
        }
    }

    private static void cross(Farmer f) {
        new Thread(f).start();
    }
}

create a bunch of random farmers