Nice features for multi-threaded applications debugging in NetBeans
This is probably old news as this feature has been out for a quite a long time, but I’d like to say to big thank-you to the NetBeans developpers to come up with a nice, very intuitive debugger for debugging multi-threaded applications in NetBeans. Kudos for the good work.
As I’ve said in a previous post, I was a long time Eclipse user (had also been an Eclipse plugin developer too between 2003 and 2005), and have switched to NetBeans recently because I had enough of Eclipse’s problems. The first impression on the NetBeans’ debugger was quite good, but as a programmer, I started to appreciate its value more and more everyday.
However, one feature that I would like to have is to be able to bind two threads into a synchronous lock step. What I mean by that is, I would like to be able to bind two threads as peers, and have the execution suspension synchronized. It means that, a thread will be suspended when I suspend its peer thread, or when its peer thread stops at a break point. This would provide a mechanism to look at the state of two threads at (almost) exactly the same point in time.
Obviously, you could emulate this feature by setting break points in the two peer threads, but the result is different, as thread execution order is non-deterministic. A purist architecture designer would rebut this argument by saying that I am not supposed to have such a messy and non-deterministic architecture, and I would agree. But realities are sometimes not exactly ideal.
The deadlock detection feature is very cool too. I threw it a few textbook cases of deadlock, and they were detected quite nicely when deadlock occurred. However, deadlock can be detected only when it occurs. This means that, if your application never runs into a deadlock situation, the debugger would not be able to tell you. In a complex application, deadlock only occurs when it is already deployed to a production system, and in a situation that is totally unreproducible. It would have been formidable if a tool is provided to analyze the code and provide a report on deadlock risks. I am not asking too much, am I?
This post is not going to demonstrate how to debug multi-threaded applications in NetBeans IDE, as very good user’s guide has already been published, and a lot of features demo can easily be found on the net. This post is meant to be a word of gratitude from a programmer to his peer programmers for having provided such a good tool to the programming community.