img
. .
Also notice that the main thread is always "Main." You can see from the thread pane that Main is
stopped in sleep(). The stack pane will show the entire call stack for the selected thread.
The tiny folders are thread groups, the double lines are threads. The dark double lines indicate
threads that have been suspended, hence "Main" and "C" were running at the time of interruption,
whereas "A," "B," and "D" have arrows, hence were all blocked in a call to wait() or sleep().
These three blocks piled on top of each other--"[1]," "[2]," and "[3]"--indicate calls on the stack
(those blocks are stacks, get it?). You can see the stack frame (and details thereof) for any thread
you choose. The graphics and interface are a bit awkward, but they are quite functional.
It is possible to single step an individual thread, or to continue all threads. No other options exist.
You can let a program run and then interrupt it. This allows you to look at deadlocked programs
and figure out the problem.
Some caution must be exercised, as the first option can get you into confusion. If you step into a
call to a synchronized section, and that lock is locked, the thread will not be able to enter that
section and JWS will allow all the other threads to run. And you may get confused.
Even in the best designed programs, it is common to have problems getting critical sections to
work exactly the way you want. When you do run into problems, it can be extremely time
consuming to find the information you need to fix them. Java locks do not appear in the debugger
at all and there is no way for you to find out which thread owns them.
Proctool
For Solaris 2 systems, there is a very nice system status display tool (Figure 14-2), which is freely
available via FTP (see Freeware Tools). It will show you all the system statistics on your program,
including the details for each individual LWP. This tool can be useful when you want to know
how your threads are behaving with respect to system calls.
Figure 14-2. Proctool, Main Display Window
Search WWH :
Custom Search
Previous Page
Multithreaded Programming with JAVA - Topic Index
Next Page
Multithreaded Programming with JAVA - Bookmarks
Home