Switching Execution Threads in a Debugging Session

This section provides a tutorial example on how to list execution threads and switch debugging control to different threads.

5. Switching threads:

main[1] cont
Breakpoint hit: "thread=main", PrimeNumberSeeker.main(), line=19 bci=25
19             System.out.println( i+", "+t.current+", "+t.count);

main[1] print t.current
 t.current = 14

main[1] print t.count
 t.count = 6

main[1] where all
  [1] PrimeNumberSeeker.main (PrimeNumberSeeker.java:19)
  [1] java.lang.Thread.sleep (native method)
  [2] PrimeNumberSeeker.run (PrimeNumberSeeker.java:42)

main[1] threads
Group main:
  (java.lang.Thread)0x1         main          running
  (PrimeNumberSeeker)0x118      Thread-0      running (at breakpoint)

main[1] thread 280

Thread-0[1] list
Current method is native

Thread-0[1] step out
11, 22, 8
Step completed: "thread=Thread-0", PrimeNumberSeeker.run(), line=45
45             }

Thread-0[1] list
41             try {
42                sleep(delay);
43             } catch (InterruptedException e) {
44                System.out.println("Runner interrupted.");
45 =>          }
46          }
47       }
48    }

Thread-0[1] print count
 count = 8

What I have done here:

Last update: 2015.

Table of Contents

 About This Book

 Java Tools Terminology

 Installing Java 8 on Windows

 'javac' - The Java Program Compiler

 'java' - The Java Program Launcher

'jdb' - The Java Debugger

 'jdb' - Java Debugger Command and Options

 Starting a Debugging Session with 'jdb'

 Debugging Applications with Separate 'jdb' Sessions

 Debugging Java Applications Remotely

 Listing Debugging Commands with 'help' Command

 PrimeNumberSeeker.java - Multi-Thread Sample Program

 Starting Debugging Session on a Multi-Thread Application

 Stepping through Statements of a Child Thread

 Checking Variable Values in a Debugging Session

 Debugging the Main Thread of a Multi-Thread Application

Switching Execution Threads in a Debugging Session

 Suspending Main Thread to Debug Child Thread

 'jconsole' - Java Monitoring and Management Console

 'jstat' - JVM Statistics Monitoring Tool

 JVM Troubleshooting Tools

 jvisualvm (Java VisualVM) - JVM Visual Tool

 'jar' - The JAR File Tool

 'javap' - The Java Class File Disassembler

 'keytool' - Public Key Certificate Tool

 'native2ascii' - Native-to-ASCII Encoding Converter

 Outdated Tutorials


 PDF Printing Version