VL-Programmieren/VL14/Aufgabe02/User.java

37 lines
709 B
Java

package VL14.Aufgabe02;
/**
* Class which represents a user.
*
* @author Sebastian Brosch
*/
public class User implements Runnable {
private int number = 0;
private long wait = 0;
/**
* Constructor to initialize a User.
*/
public User() {
this.wait = 1000;
}
/**
* Constructor to initialize a User.
*
* @param wait The time the user is waiting for creating new print jobs.
*/
public User(int wait) {
this.wait = wait;
}
public void run() {
while (this.wait > 0) {
int data = this.number++;
PrinterQueue.queue.add(data);
System.out.println("User " + Thread.currentThread().threadId() + " added " + data);
this.wait--;
}
}
}