import com.queuj.*;
public class QueueProcessor {
public static void main(String[] args) {
Queue<YourTask> queue = new Queue<>();
queue.add(new YourTask("Task 1"));
queue.add(new YourTask("Task 2"));
queue.add(new YourTask("Task 3"));
for (int i = 0; i < 5; i++) {
new Thread(() -> {
while (!queue.isEmpty()) {
YourTask task = queue.poll();
}
}).start();
}
}
}
class YourTask {
private String name;
public YourTask(String name) {
this.name = name;
}
public void process() {
System.out.println("Processing task: " + name);
}
}
import com.queuj.*;
public class BlockingQueueProcessor {
public static void main(String[] args) {
queue.add(new YourTask("Task 1"));
queue.add(new YourTask("Task 2"));
queue.add(new YourTask("Task 3"));
for (int i = 0; i < 5; i++) {
new Thread(() -> {
while (true) {
}
}).start();
}
}
}