CodeSOD: Exit Thread |
Objects left in the garage or the attic tend to multiply. If you dont 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 hasnt been touched since 2001. The original developer has left the company, theres 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 thats one way to end a Java program, its 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 doesnt need to- a call to System.exit terminates the JVM, along with all the threads in it.
| Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |