// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class TimeOut {
    private boolean done;
    public void doit() throws Exception {
        done = false;
        Thread t=new Thread(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(1000);
                    done = true;
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t.start();
        //t.join(500);
        t.join(500);
        System.out.println(done);
    }
    public static void main(String[] args) throws Exception {
        TimeOut tst = new TimeOut();
        tst.doit();
    }
}
