VL-Programmieren/VL14/Aufgabe02/User.java

37 lines
709 B
Java
Raw Permalink Normal View History

2024-05-30 09:27:24 +00:00
package VL14.Aufgabe02;
/**
* Class which represents a user.
*
* @author Sebastian Brosch
*/
public class User implements Runnable {
private int number = 0;
2024-06-10 13:20:28 +00:00
private long wait = 0;
2024-06-03 20:04:50 +00:00
/**
* 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;
}
2024-05-30 09:27:24 +00:00
public void run() {
2024-06-10 13:20:28 +00:00
while (this.wait > 0) {
int data = this.number++;
PrinterQueue.queue.add(data);
System.out.println("User " + Thread.currentThread().threadId() + " added " + data);
this.wait--;
2024-05-30 09:27:24 +00:00
}
}
}