// Java Program: Print numbers from 2 different loops using Multithreading with Priority
class FirstLoop extends Thread {
public void run() {
for (int i = 1; i <= 10; i++) {
[Link]("First Loop: " + i);
try { [Link](100); } catch (Exception e) {}
}
}
}
class SecondLoop extends Thread {
public void run() {
for (int i = 1; i <= 10; i++) {
[Link]("Second Loop: " + i);
try { [Link](100); } catch (Exception e) {}
}
}
}
public class ThreadPriorityExample {
public static void main(String[] args) {
FirstLoop t1 = new FirstLoop();
SecondLoop t2 = new SecondLoop();
// Setting thread priorities
[Link](Thread.MAX_PRIORITY); // Highest priority
[Link](Thread.MIN_PRIORITY); // Lowest priority
[Link]();
[Link]();
}
}