- 1
- 2
- 3
- 4
- 5
- 6
// inside some method
final DateFormat dateFormat = i18n.getDateFormat();
synchronized (dateFormat) {
formatedViolationDate = (violationDate != null) ?
dateFormat.format(violationDate) : "";
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+78
// inside some method
final DateFormat dateFormat = i18n.getDateFormat();
synchronized (dateFormat) {
formatedViolationDate = (violationDate != null) ?
dateFormat.format(violationDate) : "";
}
i18n.getDateFormat() возвращает статический объект DateFormat, который может использоваться несколькими потоками. В руки бы накласть тому, кто это писал.
Решение: getDateFormat() возвращает строку формата, объект формата создаем при каждом вызове.
ахуенная логика
Просто O(1) это очень быстро, шедулер не успеет переключиться на другую задачу. Поверьте, я у себя на ноутбуке три раза всё проверил
ага, "дата, когда меня изнасиловали"...
http://download.oracle.com/javase/1.4.2/docs/api/java/text/DateFormat.html
К примеру, StringBuilder потоконебезопасен, а StringBuffer наоборот (или наоборот, я их путаю).
Пользователь класса должен по названию угадать потокобезопасный он или нет (со временем вырабатываается такая привычка, например ArrayList не безопасен, а Vector соответственно безопасен).
DateFormat не безопасный, но к сожалению, но новочки часто не могут этого угадать, шарят его между тредами, и получают смешной багор
Представь себе вот такой класс
Что будет, если хуяк вызвать из пяти потоков?
С листом тоже самое примерно
All the “validation” you get is two-faced and half-hearted. Behind your back people mock you. Your parents are disgusted and ashamed of you, your “friends” laugh at your ghoulish appearance behind closed doors.
Men are utterly repulsed by you. Thousands of years of evolution have allowed men to sniff out frauds with incredible efficiency. Even trannies who “pass” look uncanny and unnatural to a man. Your bone structure is a dead giveaway. And even if you manage to get a drunk guy home with you, he’ll turn tail and bolt the second he gets a whiff of your diseased, infected axe wound.
You will never be happy. You wrench out a fake smile every single morning and tell yourself it’s going to be ok, but deep inside you feel the depression creeping up like a weed, ready to crush you under the unbearable weight.
Eventually it’ll be too much to bear – you’ll buy a rope, tie a noose, put it around your neck, and plunge into the cold abyss. Your parents will find you, heartbroken but relieved that they no longer have to live with the unbearable shame and disappointment. They’ll bury you with a headstone marked with your birth name, and every passerby for the rest of eternity will know a man is buried there. Your body will decay and go back to the dust, and all that will remain of your legacy is a skeleton that is unmistakably male.
This is your fate. This is what you chose. There is no turning back.
пора и справлять
инью тоже решил с трапами дружить. последний нормальный тут былд
представьте себе
и с трапами дружил
Гологуб?
А оказалось он говно
Хотя в лежал зелёный
Хотя и с мухами дружил