import java.util.concurrent.*; class RRTask implements Runnable { private final int threadId; public RRTask(int threadId) { this.threadId = threadId; } @Override public void run() { for (int i = 1; i <= 5; i++) { // Each thread runs 5 times System.out.println("Thread " + threadId + " is running (iteration " + i + ")"); Thread.yield(); // Simulate Round-Robin by yielding CPU time try { Thread.sleep(100); // Simulate time slice } catch (InterruptedException e) { e.printStackTrace(); } } } } public class Main { public static void main(String[] args) { int numThreads = 3; ExecutorService executor = Executors.newFixedThreadPool(numThreads); // Fixed thread pool simulates CPU scheduling for (int i = 1; i <= numThreads; i++) { executor.execute(new RRTask(i)); } executor.shutdown(); // Initiates an orderly shutdown of the executor } }