1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3
* Copyright � 2007 Sun Microsystems, Inc. All rights reserved.
4
* Use is subject to license terms.
9
<title>Debugging Threads in the IDE</title>
10
<link rel="StyleSheet" href="nbdocs://org.netbeans.modules.usersguide/org/netbeans/modules/usersguide/ide.css" type="text/css">
13
<h2>Debugging Threads in the IDE</h2>
14
<p><small><a href="#seealso">See Also</a></small></p>
15
<p>All the threads created in the current session are displayed in the Threads window.
16
You can open the Threads window by choosing Window > Debugging > Threads (Alt-Shift-7).</p>
18
<h3>Changing the Current Thread</h3>
19
<p> Only one thread is the current thread at any given time. By default, the
20
current thread is the thread within the current session from which the debugger
21
gained control. When you switch between threads to debug, the Call Stack and
22
Local Variables windows are automatically updated to reflect the data applicable
25
<p><b>To change the current thread:</b></p>
27
<li>Double-click any thread in the Threads window to make it the current thread. </li>
30
<h3>Suspending and Resuming Threads</h3>
31
<p> You can suspend execution of a thread if you think it is causing problems
32
and then later resume the thread once the problem is solved. </p>
33
<p>In the Threads window, the icon to the left of the thread name indicates whether the thread
34
is suspended or waiting to be resumed.</p>
35
<table border="1" cellpadding="5" cellspacing="0">
36
<tr align="left" valign="top">
37
<th scope="col">Icon</th>
38
<th scope="col">Description</th>
41
<td><img src="images/CurrentThread.gif" alt="Current thread"></td>
42
<td>Indicates the current thread</td>
45
<td><img src="images/RunningThread.gif" alt="Running thread"></td>
46
<td>Indicates a thread that is running and is not current</td>
49
<td><img src="images/SuspendedThread.gif" alt="Suspended thread"></td>
50
<td>Indicates a thread that is suspended and is not current</td>
53
<p>You can display the Suspend property as a boolean flag (True or False)
54
in the Threads window by clicking the columns button
55
(<img src="images/ChangeColumn.gif" alt="Change Column">) and select the Suspend checkbox. </p>
57
<li> The state of the Thread is independent of whether the thread is suspended
58
or waiting to be resumed. A thread's state may be Running while the Suspend
59
property is True. </li>
61
<p><b>To suspend or resume a thread:</b></p>
63
<li>Right-click the thread in the Threads window and choose the Resume or Suspend command. </li>
66
<h3>Multi-threaded Applications</h3>
67
<p>When debugging a multi-threaded application, a step in a particular thread may be interrupted by
68
a breakpoint encountered in some other thread.
69
This behavior is desirable in some cases but not in others.</p>
71
<p>Let us suppose you are stepping through a thread (<i>thread 1</i>),
72
and one of the steps is interrupted by a breakpoint encountered in another thread (<i>thread 2</i>).
73
When this happens, the program counter is set to the breakpoint in <i>thread 2</i>.</p>
75
<p>You can continue stepping through your program in the following ways:</p>
78
<li>Continue stepping through your program from the breakpoint in <i>thread 2</i>.</li>
79
<li>Step through the program from the previous step (in <i>thread 1</i>) and ignore the breakpoint in <i>thread 2</i>.
80
<p>To continue with the step in <i>thread 1</i>, do one of the following in the Threads window: </p>
82
<li><b>Click Ignore Breakpoint.</b> Clicking this will cause the
83
debugger to ignore the specified breakpoint encountered in <i>thread 2</i> and you can continue to step
84
through the program following <i>thread 1</i>.</li>
85
<li><b>Click Ignore All Such Breakpoints.</b>
86
Clicking this will cause the debugger to ignore all breakpoints that do not occur on <i>thread 1</i>
87
until the end of the debugging session.</li>
92
<h3>Viewing Source Code for a Thread</h3>
93
<p>You can view the source code of a thread in the IDE's Source Editor if you
94
think it is causing problems and want to examine it further.</p>
95
<p><b>To view a thread's source:</b>
97
<li>Right-click the thread in the Threads window and choose Go To Source.
98
<p> If the source of the thread is available, the Source Editor jumps to the
99
current call on the thread's call stack. </p>
103
<dt><a name="seealso">See Also</a></dt>
104
<dd><a href="debug_new_watch.html">Creating a Watch</a></dd>
105
<dd><a href="debug_callstack.html">Using the Call Stack</a></dd>
106
<dd><a href="debug_step.html">Stepping Through Your Program</a></dd>
109
<small><a href="../credits.html">Legal Notices</a></small>
110
<table border="0" cellpadding="50">
111
<tr><td> </td></tr>