-Поиск по дневнику

Поиск сообщений в rss_thedaily_wtf

 -Подписка по e-mail

 

 -Постоянные читатели

 -Статистика

Статистика LiveInternet.ru: показано количество хитов и посетителей
Создан: 06.04.2008
Записей:
Комментариев:
Написано: 0


CodeSOD: Exit Thread

Четверг, 28 Июля 2016 г. 13:30 + в цитатник

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.

[Advertisement] High availability, Load-balanced or Basic – design your own Universal Package Manager, allow the enterprise to scale as you grow. Download and see for yourself!

http://thedailywtf.com/articles/exit-thread

Метки:  

 

Добавить комментарий:
Текст комментария: смайлики

Проверка орфографии: (найти ошибки)

Прикрепить картинку:

 Переводить URL в ссылку
 Подписаться на комментарии
 Подписать картинку