import java.awt.*; import java.util.*; import java.net.*; import java.io.*; import java.applet.Applet; class Timeout extends Thread { Thread target; long timeout; public Timeout(long timeout, Thread target) { this.timeout = timeout; this.target = target; } public void run() { try { Thread.sleep(timeout); } catch (InterruptedException e) { System.err.println("Timer failed " + e.getMessage()); } target.stop(); } public void cancel() { stop(); } }