Talk:Debugging Exercises

Revision as of 12:36, 25 November 2015 by Hinerm (talk | contribs) (Outline last 2 exercises)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Exercise 8: Profiling

Used when we need information about performance

exercise: two methods, which takes more time to run?

  • open jvisualvm
  • run E8 program
  • double-click in jvisualvm
  • open “profile” tab
  • click “Settings”
  • change package to net.imagej.trouble.**
  • start profiling.

question box: which method took longer?

Exercise 9: Multiple threads

Even though no code changes, sometimes debugging affects code execution

exercise: debug once where breakpoint stops thread, once where it stops vm

  • Run E9 with no breakpoint. Note that it works fine
  • Now set a breakpoint in the “getName” method of either the Even or Odd LonelyRunnable
  • Set the breakpoints property to “Suspend thread”
  • Debug E9. After hitting the breakpoint, wait for a few seconds. Eventually you should see that a different thread is paused and “Expecting Exception”.
  • resume the threads and see the stack trace.
  • Now modify the breakpoint and tell it to suspend VM instead of just the thread
  • Debug again. When you hit a breakpoint, make sure you resume the VM and not just the thread.

Hinerm (talk)