// A pause() method for debugging // by Dan Hyde March 29, 2002 // Use AFTER a debugging System.out.println() to force a thread to wait. // Recall that printing is done in a separate thread. Therefore, // a runtime error AFTER a System.out.println() may occur before the // message is printed. import java.io.*; class TestPause { TestPause () { } void pause() // pause and wait for a Return key { String reply; try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Pausing... Hit Return key to continue: " ); reply = in.readLine(); } catch (IOException e){ System.err.println("Bad I/O " + e); } } public static void main(String[] args){ TestPause app = new TestPause (); app.pause(); // use to test pause() } }