Thread scheduler can arbitrarily choose what threads to run
public class RunThreads implements Runnable {
public static void main(String[] args) {
RunThreads runner = new RunThreads();
Thread one = new Thread(runner);
Thread two = new Thread(runner);
one.setName("First thread");
two.setName("Second thread");
one.start();
two.start();
}
@Override
public void run() {
for (int i = 0; i < 25; i++) {
String threadName = Thread.currentThread().getName();
System.out.println(threadName + " is running");
}
}
}
//illustrates how the Thread Scheduler can be arbitrary in what it chooses to run on the thread