Here's a class that extends Thread and overrides the run method:
class MyThread extends Thread {
@Override
public void run() {
System.out.println("Hello from " + getName());
}
}
And a snippet of code:
MyThread t1 = new MyThread();
t1.setName("My-thread-1");
t1.start();
t1.join();
MyThread t2 = new MyThread();
t2.setName("My-thread-2");
t2.start();
System.out.println("output-1");
t2.join();
System.out.println("output-2");
In what order may the strings be printed out? Select all possible cases.