import java.util.concurrent.*; class PriorityTask implements Runnable { private final String name; public PriorityTask(String name) { this.name = name; } @Override public void run() { for (int i = 1; i <= 5; i++) { // Each thread runs 5 iterations System.out.println(name + " is running (iteration " + i + ")"); try { Thread.sleep(100); // Simulate task execution } catch (InterruptedException e) { e.printStackTrace(); } } } } public class Main { public static void main(String[] args) { Thread highPriority = new Thread(new PriorityTask("High Priority Thread")); Thread mediumPriority = new Thread(new PriorityTask("Medium Priority Thread")); Thread lowPriority = new Thread(new PriorityTask("Low Priority Thread")); // Set thread priorities highPriority.setPriority(Thread.MAX_PRIORITY); // Priority 10 mediumPriority.setPriority(Thread.NORM_PRIORITY); // Priority 5 (default) lowPriority.setPriority(Thread.MIN_PRIORITY); // Priority 1 // Start the threads highPriority.start(); mediumPriority.start(); lowPriority.start(); } }