import java.io.*; public class AlarmThread extends Thread { private static BufferedReader b = new BufferedReader (new InputStreamReader (System.in)); private String msg = null; private int timeout = 0; public AlarmThread(String msg, int timeout) { this.msg = msg; this.timeout = timeout; } public void run() { // wait (in secs) try { Thread.sleep(timeout * 1000); } catch (InterruptedException e) { } System.out.println("("+timeout+") "+msg); } private static AlarmThread parseInput(String line) { // find the end of the first token String m = null; int t = 0; try { for (int i = 0; i "); // read user input String line = b.readLine(); if (line == null) return; Thread t = parseInput(line); if (t != null) t.start(); } } public static void main(String args[]) throws IOException { doAlarm(); } }