package com.example.tread;

public class Producer implements Runnable {

	private SyncStack theStack; // data
	private int num;
	private static int counter = 1;

	public Producer(SyncStack s) {
		theStack = s;
		num = counter++;
	}

	@Override
	public void run() {
		char c;

		// generate random character to put to stack
		for (int i = 0; i < 100; i++) {
			c = (char) (Math.random() * 26 + 'A');
			theStack.push(c);
			System.out.println("Producer" + num + ": " + c);
			try {
				Thread.sleep((int) (Math.random() * 300));
			} catch (InterruptedException e) {
				// do nothing...
			}
		}
	}

}
