Main.java 441 Bytes
Newer Older
Gabriele Civitarese's avatar
Gabriele Civitarese committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
package conditions;

public class Main {

    public static void main(String[] args) {

        int producers = 5;
        int consumers = 5;

        BoundedBuffer<String> boundedBuffer = new BoundedBuffer<>(5);

        for(int i = 0; i<consumers; i++)
            new Thread(new Consumer("c"+i, boundedBuffer)).start();

        for(int i = 0; i<producers; i++)
            new Thread(new Producer("p"+i, boundedBuffer)).start();
    }
}