Thursday, 26 June 2008

Multithread debugging

Last years Netbeans performed an incredible evolution in functionality, quality, openness and integration. I remember those days of Netbeans 3 (when I refused using it), it had a very confused way of manage projects and it was a poor tool. It was not a very good choice, in my opinion, but there was a turning point at version 5 (or maybe other version). Nowadays I think it is the best tool for Java development. I have already tried many IDEs, but no one is like Netbeans. Of course there are weaknesses, no body is perfect, but it is a really good tool.

I was reading about next version (6.5). They are planning lots of fixes and improvements. But one of them particularly kept my atention: multithreaded debugging support. This is a dream for all developers who have already worked in a multithread environment. The matter is that, in "normal" debuggers, you can debug only a single thread, meanwhile lots of things happen behind you, in other threads. But next Netbeans version will bring us this shiny tool. Check some screenshots below:

You can choose what thread you are debugging at a given moment:


And there is a very interesting "deadlock detector":

To accomplish all these features, Netbeans developers had to change threading model. Some points are summarized as follows: (as found at Netbeans Wiki)
  • Default breakpoint only suspends breakpoint thread.
  • Step only resumes current thread when invoked and suspends current thread when completed.
  • Evaluation is done resuming the current thread (other threads unsuspended by default breakpoint or step). No deadlock caused by debugger might happen as far as no thread is explicitly suspended by the user (via suspend action or some breakpoint).
  • 'Step interrupted by a breakpoint' issue does not exist with default breakpoint. (Except the stepping thread itself encounters a breakpoint.)
For more details, check Netbeans Wiki

2 comments:

Douglas Schilling Landgraf said...

Perfect post, congratulations! ;-)

Thiago Regal said...

Thanks, Douglas. You are always welcome!