Consumer.java 354 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
public class Consumer implements Runnable {

	private final Queue queue;
	private final String id;

	public Consumer(String id, Queue q) {
		this.id = id;
		queue = q;
	}

	public void run() {
		while (true) { 
			consume(queue.take()); 
		}
	}

	public void consume(String message) {
		System.out.println("Cons. " + id + ": prelevato " + message);
	}
}