Objective
Demonstrate suspending a running sample by setting a breakpoint.
Time Required
10 Minutes
Before You Start
Add the Hanoi Sample to the workspace if it is not already there. In the
repository, it is located in the project IBM Java Examples, in the package
com.ibm.ivj.examples.hanoi.
Instructions
To set the breakpoint where it will suspend the program repeatedly:
destination.addDisk(source.removeDisk());
Set it by placing the cursor somewhere in the line and selecting Breakpoint from the Edit menu, or by double-clicking on the left-hand margin next to the line.
Then run the application class, Hanoi. The Debugger browser will open the first time the program encounters the breakpoint. Step through the method. The Console window will show that the disk is moved from one post to the other as you step.
Click the Resume button .
The program will again run until it encounters the breakpoint again - when it is
about to move another disk.
To finish running the program, without stopping at breakpoints:
The program will run to the end, solving the Tower of Hanoi problem.