CodeSOD: Exit Thread
Objects left in the garage or the attic tend to multiply. If you don't clean them regularly, you find mysterious and inexplicable things have bred like rabbits. "Why is there a bag of marbles in this box, and when did I ever buy an ugly Christmas sweater?"
Without regular refactoring, the same thing can happen to your code-base. Michal is finally taking a look at a bit of code that hasn't been touched since 2001. The original developer has left the company, there's no documentation, and the SVN history has long since been discarded.
This leaves Michal with many questions. For example- why did the original developer pepper the code with dozens of calls to System.exit(0)? While that's one way to end a Java program, it's not the sort of thing you tend to scatter through the code-base like rice at a wedding. Even worse, though, the calls looked like this:
if(stopRequested){ Thread terminationThread = new Thread(new Runnable() { @Override public void run() { System.exit(0); } }); terminationThread.start(); }
No one knows why this runs in a separate thread. It certainly doesn't need to- a call to System.exit terminates the JVM, along with all the threads in it.