'jdb' - The Java Debugger
Part:
1
2
3
4
5
6
7
8
9
(Continued from previous part...)
main[1] stop in PrimeNumberSeeker.run
Set breakpoint PrimeNumberSeeker.run
main[1] cont
Period, Current int, # primes
1, 2, 0
>
Breakpoint hit: "thread=Thread-0", PrimeNumberSeeker.run(), line=28
28 primes = new int[ceiling];
Thread-0[1] threads
Group system:
(java.lang.ref.Reference$ReferenceHandler)0xe2 Reference Handler
(java.lang.ref.Finalizer$FinalizerThread)0xe1 Finalizer
(java.lang.Thread)0xe0 Signal Dispatcher
Group main:
(java.lang.Thread)0x1 main running
(PrimeNumberSeeker)0x118 Thread-0 running (at breakpoint)
Ok. What I have done so far:
- Started the debugging session with the first breakpoint at the beginning
of the main() method, which cause the execution to stop at line 13.
- Then I created the second breakpoint at the beginning of the run() method
in order to catch the sub thread.
- Then I issued the "cont" command. My application continued with the sub
thread created stopped at the breakpoint at line 28. The main thread also stopped.
- Noticed that the debugger prompt is changed from "main[1]" to "Thread-0[1]".
This is to inform you that you are currently in the sub thread, no longer in
the main thread.
- The I used the "threads" command to list all threads. I saw two thread groups:
"system" and "main". Of course, I am not interested in the "system" group at this point.
The "main" shows two threads: "main" (my monitoring thread) and "Thread-0" (my sub thread
working on the calculation).
- Thread "Thread-0" status shows "running (at breakpoint)". But the word "running" is referring
to the thread execution mode, not the current execution status.
- Notice that tread "main" is also stopped at this moment. As a general rule, if one thread
is stopped, all other threads are stopped also.
2. Stepping through the sub thread:
Thread-0[1] where all
Signal Dispatcher:
Finalizer:
[1] java.lang.Object.wait (native method)
[2] java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:111)
[3] java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:127)
[4] java.lang.ref.Finalizer$FinalizerThread.run (Finalizer.java:...
Reference Handler:
[1] java.lang.Object.wait (native method)
[2] java.lang.Object.wait (Object.java:429)
[3] java.lang.ref.Reference$ReferenceHandler.run (Reference.java...
main:
[1] java.lang.Thread.sleep (native method)
[2] PrimeNumberSeeker.main (PrimeNumberSeeker.java:21)
Thread-0:
[1] PrimeNumberSeeker.run (PrimeNumberSeeker.java:28)
Thread-0[1] next
2, 2, 0
>
Step completed: "thread=Thread-0", PrimeNumberSeeker.run(), line=29
29 while (count < ceiling) {
Thread-0[1] where all
...
main:
[1] java.lang.Thread.sleep (native method)
[2] PrimeNumberSeeker.main (PrimeNumberSeeker.java:21)
Thread-0:
[1] PrimeNumberSeeker.run (PrimeNumberSeeker.java:29)
Thread-0[1] next
3, 2, 0
>
30 current++;
Thread-0[1] next
4, 3, 0
>
31 int j = 2;
(Continued on next part...)
Part:
1
2
3
4
5
6
7
8
9
|