public class Join {
public static void main (String [] args) throws Exception {
Controller c = new Controller();
c.start();
Thread.sleep(100);
c.interrupt();
}
}
class Job extends Thread {
@Override
public void run() {
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}
class Controller extends Thread {
@Override
public void run() {
try {
Job j = new Job();
j.start();
j.join(1000);
if (j.isAlive())
System.out.println("job is still alice");
} catch (InterruptedException ex) {
System.out.println("interrupteded while joning");
}
}
}